N, M = map(int, raw_input().split())
ks_s = []
for i in range(M):
    ks_s.append(map(int, raw_input().split()))

ps = map(int, raw_input().split())

ans = 0
for i in range(2**N):
    flag = True
    for j in range(M):
        p = ps[j]
        k = ks_s[j][0]
        num_on = 0
        for l in range(1, k+1):
            s = ks_s[j][l]
#            print i, j, l, s, bin(i), bin(1<<s)                                                       
            if 1 << s-1 & i:
                num_on = num_on + 1
        if num_on % 2 != p:
            flag = False
#            break                                                                                     

    if flag:
        ans = ans + 1

print ans
