l = raw_input().split()
N = int(l[0])
M = int(l[1])

K = []
S = []
P = []

for i in range(M):
    l = raw_input().split()
    t = [int(x) for x in l]
    K.append(t[0])
    S.append(t[1:])

l = raw_input().split()
P = [int(x) for x in l]

# print(N, M, K, S, P)

def numBits(n):
    count = 0
    while n > 0:
        if n % 2 == 1:
            count += 1
        n /= 2
    return count

def solve(n, S, p):
    # print('nsp', n, S, p)
    count = 0
    for s in S:
        # print(s, n, n >> (s - 1))
        count += (n >> (s - 1)) & 1
    # print('count={}'.format(count))
    return p == (count  & 1)

ans = 0
for j in range(2**N):
    # print(j)
    ret = True
    for i in range(len(S)):
        s = S[i]
        p = P[i]
        # print(i, s, p)
        if not solve(j, s, p):
            ret = False
            break
    if ret:
        ans += 1
print(ans)
