N,M = map(int,input().split())
a = [0 for i in range(N)]
p = 0
ans = 0
for i in range(M):
    k,*s = map(int,input().split())
    for j in s:
        a[j-1] |= 1 << i

ps = list(map(int,input().split()))
for i,j in enumerate(ps):
    p |= j << i
for i in range(1<<N):
    t = 0
    for j in range(N):
        if(i>>j & 1):
            t ^= a[j]
    if t is p:
        ans += 1

print(ans)
#print(p)
#print(a)