N, M = map(int, input().split())

lst = []
for i in range(N):
    ks = list(map(int,input().split()))
    lst.append(ks[1:])

p = list(map(int, input().split()))

c = 0

for j in range(2**N):
    for k, l in enumerate(p):
        msk = 0
        for b in lst[k]:
            msk += 2**(b-1)
        if bin(j&msk).count('1') % 2 != l:
            break
    else:
        c += 1

print(c)
    
