import math

n,m = map(int, input().split())
A = []
for _ in range(m):
    ks = list(map(int,input().split()))
    A.append(ks)
P = list(map(int, input().split()))

prob = 1
for i in range(m):
    ks = A[i]
    k,s = ks[0],ks[1:]
    p = P[i]
    c = 0
    if p == 0:
        for j in range(0,k+1,2):
            c += math.factorial(k) / (math.factorial(j)*math.factorial(k-j))
    else:
        for j in range(1,k+1,2):
            c += math.factorial(k) / (math.factorial(j)*math.factorial(k-j))
    prob *= c*2**(n-k) / (2**n)
    
print(int(2**n*prob))