n,m = map(int,input().split())
s = [0]*n
for i in range(m):
    k = list(map(int,input().split()))
    for j in range(1,k[0]+1):
        s[k[j]-1] |= 1<<i
p=0
k = list(map(int,input().split()))
for i in range(m):
    p |= k[i]<<i
ans = 0
for i in range(1<<n):
    t = 0
    for j in range(n):
        if i>>j&1: t^=s[j]
    if t==p: ans+=1
print(ans)