import itertools
n,m = map(int,input().split())
k = []
s = []
for i in range(m):
    temp = list(map(int,input().split()))
    k.append(temp[0])
    s.append(temp[1:])
p = list(map(int,input().split()))

z = list(itertools.combinations_with_replacement([1,0],n))
ans = 0
for i in z:
    ad = True
    for j in range(m):
        cnt = 0
        for l in range(k[j]):
            if i[s[j][l]-1] == 1:
                cnt += 1
        if not cnt%2 == p[j]:
            ad = False
            break
    if ad:
        ans += 1
print(ans)