N,M = map(int, input().split())
 
s = [list(map(int, input().split()))[1:] for _ in range(M)]
p = list(map(int, input().split()))

cnt = 0

for i in range(2 ** N):
    flag = True
    for j in range(M):
        if not([(i >> k-1) for k in s[j]].count(1) % 2 == p[j] & 1):
            flag = False
    if flag:
        cnt += 1

print(cnt)