N, M = map(int, input().split())
k = []
lis = []
P = []
for _ in range(M):
    x = list(map(int, input().split()))
    k.append(x[0])
    lis.append(x[1:])
for p in map(int, input().split()):
    P.append(p)
count = 0
for i in range(2**N):
    flag = True
    string = str(bin(i)[2:])[::-1]
    for index in range(M):
        total = 0
        for s in lis[index]:
            if s < len(string):
                if string[s - 1] == '1':
                    total += 1
        if total % 2 != P[index]:
            flag = False
            break
    if flag:
        count += 1
print(count)