n,m = map(int,input().split())
k = []
s = []
for i in range(m):
    x = tuple(map(int,input().split()))
    k.append(x[0])
    s.append(x[1:])
p = list(map(int,input().split()))
ans = 0
for i in range(1<<n):
    flag = [0] * m
    cnt = 0
    for j,sj in enumerate(s):
        for l in sj:
            if i >> (l-1) & 1:
                cnt += 1
        if cnt % 2 == p[j]:
            flag[j] = 1
    if all(flag):
        ans+=1
print(ans)