N,M = map(int, input().split())
lamps = []
for i in range(M):
    lamps.append([int(x) for x in input().split()[1:]])
P = [int(x) for x in input().split()]

def popcnt0(n):
    c = 0
    for i in range(64):
        c += (n >> i) & 1
    return c

case = 0
for i in range(2**N):
    on = 1
    for j in range(M):
        lamps[j] = [2**(x-1) for x in lamps[j]]
        #print("i={:04b},j={},{:04b}, {}, p={}".format(i, j, i & sum(lamps[j]), popcnt0(i & sum(lamps[j]))%2, P[j]))
        if popcnt0(i & sum(lamps[j]))%2 != P[j]:
            on = 0
            break
    case += on

print(case)