There are n lamps on a line, numbered from 1 to n. Each one has an initial state off (0) or on (1).

You're given k subsets A_1, …, A_k of \{1, 2, ..., n\}, such that the intersection of any three subsets is empty. In other words, for all 1 ≤ i_1 < i_2 < i_3 ≤ k, A_{i_1} ∩ A_{i_2} ∩ A_{i_3} = ∅.

In one operation, you can choose one of these k subsets and switch the state of all lamps in it. It is guaranteed that, with the given subsets, it's possible to make all lamps be simultaneously on using this type of operation.

Let m_i be the minimum number of operations you have to do in order to make the i first lamps be simultaneously on. Note that there is no condition upon the state of other lamps (between i+1 and n), they can be either off or on.

You have to compute m_i for all 1 ≤ i ≤ n.

Input

The first line contains two integers n and k (1 ≤ n, k ≤ 3 ⋅ 10^5).

The second line contains a binary string of length n, representing the initial state of each lamp (the lamp i is off if s_i = 0, on if s_i = 1).

The description of each one of the k subsets follows, in the following format:

The first line of the description contains a single integer c (1 ≤ c ≤ n) — the number of elements in the subset.

The second line of the description contains c distinct integers x_1, …, x_c (1 ≤ x_i ≤ n) — the elements of the subset.

It is guaranteed that: 

  * The intersection of any three subsets is empty; 
  * It's possible to make all lamps be simultaneously on using some operations. 

Output

You must output n lines. The i-th line should contain a single integer m_i — the minimum number of operations required to make the lamps 1 to i be simultaneously on.

Examples

Input


7 3
0011100
3
1 4 6
3
3 4 7
2
2 3


Output


1
2
3
3
3
3
3


Input


8 6
00110011
3
1 3 8
5
1 2 5 6 7
2
6 8
2
3 5
2
4 7
1
2


Output


1
1
1
1
1
1
4
4


Input


5 3
00011
3
1 2 3
1
4
3
3 4 5


Output


1
1
1
1
1


Input


19 5
1001001001100000110
2
2 3
2
5 6
2
8 9
5
12 13 14 15 16
1
19


Output


0
1
1
1
2
2
2
3
3
3
3
4
4
4
4
4
4
4
5

Note

In the first example: 

  * For i = 1, we can just apply one operation on A_1, the final states will be 1010110; 
  * For i = 2, we can apply operations on A_1 and A_3, the final states will be 1100110; 
  * For i ≥ 3, we can apply operations on A_1, A_2 and A_3, the final states will be 1111111. 



In the second example: 

  * For i ≤ 6, we can just apply one operation on A_2, the final states will be 11111101; 
  * For i ≥ 7, we can apply operations on A_1, A_3, A_4, A_6, the final states will be 11111111. 
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
/*

 */
public class C {
	
	public static void main(String[] args) {
		Scanner fs=new Scanner(System.in);
		int nLamps=fs.nextInt();
		int nSubsets=fs.nextInt();
		boolean[] xorOne=new boolean[nLamps];
		char[] line=fs.next().toCharArray();
		
		for (int i=0; i<nLamps; i++) xorOne[i]=line[i]=='0';
		DisjointSet dj=new DisjointSet(nSubsets*2);
		for (int i=0; i<nSubsets; i++)
			dj.sizeOf[nSubsets+i]=0;//we don't actually have to flip any switches
		
		ArrayList<Integer>[] subsetsOf=new ArrayList[nLamps];
		for (int i=0; i<nLamps; i++) {
			subsetsOf[i]=new ArrayList<>();
		}
		for (int s=0; s<nSubsets; s++) {
			int k=fs.nextInt();
			for (int i=0; i<k; i++) {
				int lamp=fs.nextInt()-1;
				subsetsOf[lamp].add(s);
				if (subsetsOf[lamp].size()>2) throw null;
			}
		}
		PrintWriter out=new PrintWriter(System.out);
		
		for (int lamp=0; lamp<nLamps; lamp++) {
			if (subsetsOf[lamp].size()==0) {
				//hope we are okay because they say we will be
			}
			else if (subsetsOf[lamp].size()==1) {
				int subset=subsetsOf[lamp].get(0);
				if (xorOne[lamp]) {
					dj.markImpossible(subset+nSubsets);
				}
				else {
					dj.markImpossible(subset);
				}
			}
			else {
				//otherwise we have two choices
				int s1=subsetsOf[lamp].get(0), s2=subsetsOf[lamp].get(1);
				if (xorOne[lamp]) {
					//then they have to be different
					dj.dualUnion(s1, s2+nSubsets, s1+nSubsets, s2);
//					dj.union(s1, s2+nSubsets);
//					dj.union(s1+nSubsets, s2);
				}
				else {
					//they have to be the same
					dj.dualUnion(s1, s2, s1+nSubsets, s2+nSubsets);
//					dj.union(s1, s2);
//					dj.union(s1+nSubsets, s2+nSubsets);
				}
			}
			
			
			//TODO: print answer, left as an exercise to reader
			out.println(/* "Cur ans: "+ */dj.minSize);
		}
		out.close();
	}
	
	static class DisjointSet {
		int half;
		int[] s;
		int[] sizeOf;
		boolean[] impossible;

		int minSize=0;
		
		public DisjointSet(int n) {
			half=n/2;
			Arrays.fill(s = new int[n], -1);
			sizeOf=new int[n];
			Arrays.fill(sizeOf, 1);
			impossible=new boolean[n];
		}
		
		public int find(int i) {
			return s[i] < 0 ? i : (s[i] = find(s[i]));
		}
		
		public void markImpossible(int i) {
			i=find(i);
//			System.out.println("Marking "+i+" as impossible");
			minSize-=costChoice(i);
			impossible[i]=true;
			minSize+=costChoice(i);
		}
		
		public void dualUnion(int a, int b, int c, int d) {
			a=find(a); b=find(b); c=find(c); d=find(d);
//			System.out.println("Unioning "+a+" and "+b+" subtracted "+costChoice(a)+" and "+costChoice(b));
			if (a!=b) {
				minSize-=costChoice(a);
				minSize-=costChoice(b);
				union(a, b);				
				union(c, d);
				minSize+=costChoice(a);
//				System.out.println("Added in "+costChoice(a));
			}
		}
		
		public boolean union(int a, int b) {
			if ((a = find(a)) == (b = find(b))) return false;
			if(s[a] == s[b]) s[a]--;
			
			
			if(s[a] <= s[b]) {
				s[b] = a;
				sizeOf[a]+=sizeOf[b];
				impossible[a]|=impossible[b];
			}
			else {
				s[a] = b;
				sizeOf[b]+=sizeOf[a];
				impossible[b]|=impossible[a];
			}
			a=find(a);
			
			return true;
		}
		
		int costChoice(int i) {
			int other=i<half?i+half:i-half;
			i=find(i);
			other=find(other);
			
			if (impossible[i]) return sizeOf[other];
			if (impossible[other]) return sizeOf[i];
			
			return Math.min(sizeOf[i], sizeOf[other]);
		}
	}
	
	
}
