n,m = map(int, input().split())
s = []
for i in range(m):
    k = list(map(int, input().split()))
    K = []
    for i in k:
        K.append(i-1)
    s.append(K[1:])
p = list(map(int, input().split()))

# print("n,m:",n,m)
# print("s:",s)
# print("p:",p)

def bitlist(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

ans = 0
for i in range(2**n):
    bitnow = bitlist(i,n)
    checker = 0
    flag = 0
    for j in range(m):
        for l in s[j]:
            if bitnow[l]==1:
                checker += 1
        if checker%2 != p[j]:
            flag = 1
    if flag == 0:
        ans += 1

print(ans)
