from itertools import product 
n,m = map(int,input().split())
lamp = [list(map(int,input().split())) for _ in range(m)]
p = list(map(int,input().split()))

ans = 0
for i in product([0,1],repeat=n):
    tmp = 0
    ac = True
    for k,b in enumerate(lamp):
        for a in b[1:]:
            tmp += int(i[a-1])
        tmp %= 2
        if p[k] != tmp:
            ac = False
            break
    if ac:
        ans += 1
print(ans)