n,m = map(int,input().split())
ks = [[int(i) for i in input().split()] for _ in range(m)]
p = list(map(int,input().split()))

ans=0
for i in range(2**n):
    sw=[]
    on=0
    for j in range(n):
        sw.append(i>>j & 1)
    for k in range(m):
        if (sum( [sw[ks[k][j+1]-1] for j in range(ks[k][0])] ))%2 == p[k]:
            on +=1
    if on==m:
        ans +=1
print(ans) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m [int(i) for i in input().split()] for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) [int(i) for i in input().split()] ks = [[int(i) for i in input().split()] for _ in range(m)] ks [[int(i) for i in 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 ans=0 ans 0 for i in range(2**n):
    sw=[]
    on=0
    for j in range(n):
        sw.append(i>>j & 1)
    for k in range(m):
        if (sum( [sw[ks[k][j+1]-1] for j in range(ks[k][0])] ))%2 == p[k]:
            on +=1
    if on==m:
        ans +=1 i range(2**n) range 2**n 2 n sw=[] sw [] on=0 on 0 for j in range(n):
        sw.append(i>>j & 1)
     j range(n) range n sw.append(i>>j & 1) sw.append sw append i>>j & 1 i>>j i j 1 for k in range(m):
        if (sum( [sw[ks[k][j+1]-1] for j in range(ks[k][0])] ))%2 == p[k]:
            on +=1
     k range(m) range m if (sum( [sw[ks[k][j+1]-1] for j in range(ks[k][0])] ))%2 == p[k]:
            on +=1
     (sum( [sw[ks[k][j+1]-1] for j in range(ks[k][0])] ))%2 == p[k] (sum( [sw[ks[k][j+1]-1] for j in range(ks[k][0])] ))%2 sum( [sw[ks[k][j+1]-1] for j in range(ks[k][0])] ) sum [sw[ks[k][j+1]-1] for j in range(ks[k][0])] 2 p[k] p k on +=1 on 1 if on==m:
        ans +=1 on==m on m ans +=1 ans 1 print(ans) print ans ks = [[int(i) for i in input().split()] for _ in range(m)] [[int(i) for i in input().split()] for _ in range(m)] ks ans=0 0 ans p = list(map(int,input().split())) list(map(int,input().split())) p sw=[] [] sw ans +=1 1 ans on +=1 1 on n,m = map(int,input().split()) map(int,input().split()) n on=0 0 on m = map(int,input().split()) map(int,input().split()) m
n,m = map(int,input().split())
ks = [[int(i) for i in input().split()] for _ in range(m)]
p = list(map(int,input().split()))

ans=0
for i in range(2**n):
    sw=[]
    on=0
    for j in range(n):
        sw.append(i>>j & 1)
    for k in range(m):
        if (sum( [sw[ks[k][j+1]-1] for j in range(ks[k][0])] ))%2 == p[k]:
            on +=1
    if on==m:
        ans +=1
print(ans)
