n, m = map(int, input().split())

ss = []
for i in range(m):
    s = list(map(int, input().split()))[1:]
    te = 0
    for sm in s:
        te += 2**(sm-1)
    ss.append(te)

pp = list(map(int, input().split()))
res = 0
for i in range(2**(n-1)):
    tm = True
    for j in range(len(ss)):
        if (i & ss[j]) % 2 != pp[j]:
            tm = False
            break
    if tm:
        res += 1
print(res)