import numpy as np
N, M = map(int, input().split())
lists = []
for _ in range(M):
    lists.append(list(map(int, input().split()))[1:])
p_list = list(map(int, input().split()))
num = 0
len_m = N
for n in range(2 ** N):
    flag = True
    for p, lis in zip(p_list, lists):
        flag = flag & ((sum([f'{n:0{len_m}b}'[l - 1] == '1' for l in lis]) % 2) == p)
    num += flag
print(num)