import numpy as np

N,M=map(int,input().split())
ks=np.array([[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にスイッチのオンオフを記録
    sw=[0]*N
    for j in range(N):
        if (i>>j)&1:
            sw[j]=1

    count=0
    for denkyu_no in range(M):
        if sum([sw[ks[denkyu_no][j+1]-1] for j in range(ks[denkyu_no][0])])%2 ==p[denkyu_no]:
            count +=1

    if count==M:
        ans+=1
print(ans) import numpy as np numpy 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=np.array([[int(i) for i in input().split()] for _ in range(M)]) ks np.array([[int(i) for i in input().split()] for _ in range(M)]) np.array np array [[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にスイッチのオンオフを記録
    sw=[0]*N
    for j in range(N):
        if (i>>j)&1:
            sw[j]=1

    count=0
    for denkyu_no in range(M):
        if sum([sw[ks[denkyu_no][j+1]-1] for j in range(ks[denkyu_no][0])])%2 ==p[denkyu_no]:
            count +=1

    if count==M:
        ans+=1 i range(2**N) range 2**N 2 N sw=[0]*N sw [0]*N [0] 0 N for j in range(N):
        if (i>>j)&1:
            sw[j]=1

     j range(N) range N if (i>>j)&1:
            sw[j]=1

     (i>>j)&1 i>>j i j 1 sw[j]=1 sw[j] sw j 1 count=0 count 0 for denkyu_no in range(M):
        if sum([sw[ks[denkyu_no][j+1]-1] for j in range(ks[denkyu_no][0])])%2 ==p[denkyu_no]:
            count +=1

     denkyu_no range(M) range M if sum([sw[ks[denkyu_no][j+1]-1] for j in range(ks[denkyu_no][0])])%2 ==p[denkyu_no]:
            count +=1

     sum([sw[ks[denkyu_no][j+1]-1] for j in range(ks[denkyu_no][0])])%2 ==p[denkyu_no] sum([sw[ks[denkyu_no][j+1]-1] for j in range(ks[denkyu_no][0])])%2 sum([sw[ks[denkyu_no][j+1]-1] for j in range(ks[denkyu_no][0])]) sum [sw[ks[denkyu_no][j+1]-1] for j in range(ks[denkyu_no][0])] 2 p[denkyu_no] p denkyu_no count +=1 count 1 if count==M:
        ans+=1 count==M count M ans+=1 ans 1 print(ans) print ans N,M=map(int,input().split()) map(int,input().split()) N count +=1 1 count p=list(map(int,input().split())) list(map(int,input().split())) p M=map(int,input().split()) map(int,input().split()) M ks=np.array([[int(i) for i in input().split()] for _ in range(M)]) np.array([[int(i) for i in input().split()] for _ in range(M)]) ks count=0 0 count sw=[0]*N [0]*N sw ans+=1 1 ans ans=0 0 ans
import numpy as np

N,M=map(int,input().split())
ks=np.array([[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にスイッチのオンオフを記録
    sw=[0]*N
    for j in range(N):
        if (i>>j)&1:
            sw[j]=1

    count=0
    for denkyu_no in range(M):
        if sum([sw[ks[denkyu_no][j+1]-1] for j in range(ks[denkyu_no][0])])%2 ==p[denkyu_no]:
            count +=1

    if count==M:
        ans+=1
print(ans)