import numpy as np
n, m = map(int,input().split())

ks = np.array([list(map(int,input().split()[1:])) for _ in range(m)])

ss = np.array(list(map(int,input().split())))

def ans(n):
    return(b1(n,[])+b0(n,[]))

def b0(n,t):
    global ss
    if n == 2:
        return 0
    return b0(n-1,t)+b1(n-1,t)

def b1(n,t):
    global ks
    global ss
    t = np.array([int(n in k) for k in ks])
    if n == 2:
        return all([i%2 for i,j in zip(t,ss)])
    return b0(n-1,t)+b1(n-1,t)

print(ans(n))