# coding: utf-8
# Your code here!
n,m = map(int,input().split())
s = [list(map(int,input().split())) for _ in range(m)]
p = list(map(int,input().split()))
n2 = [0]*n
cnt = 0
on = 0
ans = 0
for _ in range(2**n):
    check = 0
    on = 0
    #電球チェック
    for i in range(m):
        for k in range(s[i][0]):
            if n2[s[i][k+1]-1] == 1:
                check += 1
        else:
            if check%2 == p[i]:
                on += 1
    else:
        if on == m:
            ans +=1
    #他の組み合わせ
    for j in range(n):
        if n2[j] == 0:
            n2[j] = 1
            cnt +=1
            break
        else:
            n2[j] = 0
            cnt -=1
            continue
print(ans)