from collections import defaultdict

n, m = map(int, input().split())
li_ord = [0 for _ in range(m)]
dic = defaultdict(list)

for i in range(m):
    s = list(map(int, input().split()))[1:]
    for j in s:
        dic[j].append(i)
p = list(map(int, input().split()))
dic = sorted(dict(dic).items())
ans = 0

if dic == []:
    if 1 in p:
        print(0)
    else:
        print(2**n)
    exit()

for i in range(2**n):
    tmp_num = bin(i)[2:].zfill(n)
    li = li_ord
    for j in range(n):
        digit = tmp_num[j]
        #print(digit, dic[j][1])
        if digit == '1':
            for k in dic[j][1]:
                #print(li[k], k)
                li[k] ^= 1
    #print(tmp_num, p, li)
    if p == li:
        ans += 1

print(ans)