import numpy as np
N, M = list(map(int, input().split()))
Switches = np.zeros((N,M)) # N = Switch, M = light

for i in range(M):
    arr = list(map(int, input().split()))
    for item in arr[1:]:
        Switches[item-1, i] = 1
Ps = np.array(list(map(int, input().split())))

bit_max = 2 ** N
stat = np.zeros(M)
cnt = 1 if (stat == Ps).all() else 0

for i in range(1, bit_max):
    bits = [j for j in range(M) if (i >> j &1)]
    res = stat + Switches[bits].sum(axis=0) % 2
    cnt += 1 if (res == Ps).all() else 0

print(cnt)