N, M = map(int, input().split())
switch_state = [None] * N
which_switch = []

for i in range(M):
    which_switch.append(list(map(int, input().split())))
    del(which_switch[i][0])

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

cnt = 0
for i in range(1<<N):
    flag = 0
    for j in range(M):
        check = 0
        for el in which_switch[j]:
            check += (1<<(el-1))
            if str(bin(i & check)).count('1') % 2 != p[j]:
                flag = 1
                break
        if flag == 1:
            break
        cnt += 1
        
print(cnt)