N,M=map(int,input().split())

S=[[] for _ in range(N+1)]
for i in range(M):
    T=list(map(int,input().split()))
    for x in T[1:]:
        S[x].append(i+1)

P=["*"]+list(map(int,input().split()))

X=0
for i in range(2**N):
    Q=["*"]+[0]*M
    for x in range(N):
        if i%2:
            for k in S[x+1]:
                Q[k]=(Q[k]+1)%2
                
        i>>=1
    X+=(P==Q)
print(X) N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M [] for _ in range(N+1) for _ in range(N+1) _ range(N+1) range N+1 N 1 for _ in range(N+1) [] S=[[] for _ in range(N+1)] S [[] for _ in range(N+1)] for i in range(M):
    T=list(map(int,input().split()))
    for x in T[1:]:
        S[x].append(i+1) i range(M) range M T=list(map(int,input().split())) T list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split for x in T[1:]:
        S[x].append(i+1) x T[1:] T 1: 1 S[x].append(i+1) [x].append [x] S x append i+1 i 1 P=["*"]+list(map(int,input().split())) P ["*"]+list(map(int,input().split())) ["*"] "*" list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split X=0 X 0 for i in range(2**N):
    Q=["*"]+[0]*M
    for x in range(N):
        if i%2:
            for k in S[x+1]:
                Q[k]=(Q[k]+1)%2
                
        i>>=1
    X+=(P==Q) i range(2**N) range 2**N 2 N Q=["*"]+[0]*M Q ["*"]+[0]*M ["*"] "*" [0]*M [0] 0 M for x in range(N):
        if i%2:
            for k in S[x+1]:
                Q[k]=(Q[k]+1)%2
                
        i>>=1
     x range(N) range N if i%2:
            for k in S[x+1]:
                Q[k]=(Q[k]+1)%2
                
         i%2 i 2 for k in S[x+1]:
                Q[k]=(Q[k]+1)%2
                
         k S[x+1] S x+1 x 1 Q[k]=(Q[k]+1)%2 Q[k] Q k (Q[k]+1)%2 Q[k]+1 Q[k] Q k 1 2 i>>=1 i 1 X+=(P==Q) X P==Q P Q print(X) print X M=map(int,input().split()) map(int,input().split()) M T=list(map(int,input().split())) list(map(int,input().split())) T i>>=1 1 i X=0 0 X N,M=map(int,input().split()) map(int,input().split()) N P=["*"]+list(map(int,input().split())) ["*"]+list(map(int,input().split())) P X+=(P==Q) P==Q X S=[[] for _ in range(N+1)] [[] for _ in range(N+1)] S Q=["*"]+[0]*M ["*"]+[0]*M Q
N,M=map(int,input().split())

S=[[] for _ in range(N+1)]
for i in range(M):
    T=list(map(int,input().split()))
    for x in T[1:]:
        S[x].append(i+1)

P=["*"]+list(map(int,input().split()))

X=0
for i in range(2**N):
    Q=["*"]+[0]*M
    for x in range(N):
        if i%2:
            for k in S[x+1]:
                Q[k]=(Q[k]+1)%2
                
        i>>=1
    X+=(P==Q)
print(X)
