N,M = list(map(int,input().split()))
ks =  [list(map(int,input().split())) for _ in range(M)]
p = list(map(int,input().split()))

Nlen = 2**N
ans = 0

for i in range(Nlen):
    total = 0
    for j in range(M):
        count = 0
        for k in range(1,ks[j][0]+1): 
            if i & 2**(ks[j][k]-1) == 2**(ks[j][k]-1):
                count += 1
        if count % 2 == p[j]:
            total += 1
    if total == M:
        ans += 1

print(ans) N,M = list(map(int,input().split())) N list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split M list(map(int,input().split())) for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split ks =  [list(map(int,input().split())) for _ in range(M)] ks [list(map(int,input().split())) for _ in range(M)] p = list(map(int,input().split())) p list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split Nlen = 2**N Nlen 2**N 2 N ans = 0 ans 0 for i in range(Nlen):
    total = 0
    for j in range(M):
        count = 0
        for k in range(1,ks[j][0]+1): 
            if i & 2**(ks[j][k]-1) == 2**(ks[j][k]-1):
                count += 1
        if count % 2 == p[j]:
            total += 1
    if total == M:
        ans += 1 i range(Nlen) range Nlen total = 0 total 0 for j in range(M):
        count = 0
        for k in range(1,ks[j][0]+1): 
            if i & 2**(ks[j][k]-1) == 2**(ks[j][k]-1):
                count += 1
        if count % 2 == p[j]:
            total += 1
     j range(M) range M count = 0 count 0 for k in range(1,ks[j][0]+1): 
            if i & 2**(ks[j][k]-1) == 2**(ks[j][k]-1):
                count += 1
         k range(1,ks[j][0]+1) range 1 ks[j][0]+1 ks[j][0] [j] ks j 0 1 if i & 2**(ks[j][k]-1) == 2**(ks[j][k]-1):
                count += 1
         i & 2**(ks[j][k]-1) == 2**(ks[j][k]-1) i & 2**(ks[j][k]-1) i 2**(ks[j][k]-1) 2 ks[j][k]-1 ks[j][k] [j] ks j k 1 2**(ks[j][k]-1) 2 ks[j][k]-1 ks[j][k] [j] ks j k 1 count += 1 count 1 if count % 2 == p[j]:
            total += 1
     count % 2 == p[j] count % 2 count 2 p[j] p j total += 1 total 1 if total == M:
        ans += 1 total == M total M ans += 1 ans 1 print(ans) print ans total += 1 1 total ans += 1 1 ans count = 0 0 count ks =  [list(map(int,input().split())) for _ in range(M)] [list(map(int,input().split())) for _ in range(M)] ks Nlen = 2**N 2**N Nlen ans = 0 0 ans count += 1 1 count N,M = list(map(int,input().split())) list(map(int,input().split())) N total = 0 0 total M = list(map(int,input().split())) list(map(int,input().split())) M p = list(map(int,input().split())) list(map(int,input().split())) p
N,M = list(map(int,input().split()))
ks =  [list(map(int,input().split())) for _ in range(M)]
p = list(map(int,input().split()))

Nlen = 2**N
ans = 0

for i in range(Nlen):
    total = 0
    for j in range(M):
        count = 0
        for k in range(1,ks[j][0]+1): 
            if i & 2**(ks[j][k]-1) == 2**(ks[j][k]-1):
                count += 1
        if count % 2 == p[j]:
            total += 1
    if total == M:
        ans += 1

print(ans)