n,m = map(int,input().split())
t = []

for i in range(m):
    t.append(list(map(int,input().split())))
q = list(map(int,input().split()))

x = 0
import math


for switch_cond in range(2**n):
    s = []

    for i in range(n):
        if switch_cond%2 == 0:
            s.append(0)
            switch_cond = switch_cond//2
        else:
            s.append(1)
            switch_cond = (switch_cond-1)//2
    #print("s",s)
    for j in range(m):
        #print("t[",j,"]",t[j])
        for r in range(n):
            if r+1 not in t[j][1:]:
                s[r]=0
        if q[j]%2!=s.count(1)%2:
            break
    else:
        x += 1
print(x)

