import itertools

N,M = map(int,input().split())
KS = [list(map(int,input().split())) for i in range(M)]
P = list(map(int,input().split()))
l = []
nums = [0,1]
count = 0
for b in itertools.product(nums, repeat=N):
    c_denkyu = 0
    for sw in KS:
        c_sw = 0
        for i in sw[1:]:
            if b[i-1] == 1:
                c_sw += 1
        if c_sw%2 == 0 and c_sw > 0:
            c_denkyu += 1
    if c_denkyu == N:
        count += 1
print(count)
