# cs: c nnected switches
n, m = map(int, input().split())

def get_switch_number():
    # k s1 s2 s3 .. sn 
    # k is not use.
    sn = 0
    for s in list(map(int, input().split()))[1:]:
        sn |= (1<<(s-1))
    return sn
    
cs = [get_switch_number() for _ in range(m)]
# print(f'cs: {cs}')
ps = list(map(int, input().split()))
# print(f'ps: {ps}')

# bit全探索(0: すべてoffは不要)
ans = 0
# on: 0:消えてる、1:点いてる
# 10: 1 2  3   4 
# 0b: 1 10 11, 100..
for on in range(1, 1<<n):
    # print(f'on: {on}')
    all_on = True
    i = 0
    # on と cs(conected_switch) の全パターンをチェック
    for s in cs:
        # print(f's: {s}')
        # bin: バイナリ文字列に変換
        # 3 -> '0b11'
        # list で 1 or 0 の配列を作成 ['1', '1']
        ct = len([n for n in list(bin(on&s)[2:]) if n == '1'])
        if (ct == 0) or (ct%2 != ps[i]):
            all_on = False
            break
        i += 1
    if all_on:
        ans += 1

print(ans)
