import numpy as np
tl = np.array([0,1,2,1,1,])
tl = np.array([0,1,2,1,1,])
dp = np.zeros((10,10))
ans = 0
n,m = map(int,input().split())
for i in range(m):
    tl = list(map(int,input().split()))
    for j in tl[1:]:
        dp[i][j-1]+=1
l = list(map(int,input().split()))
import itertools
for i in range(1,n+1):
    bp=np.zeros(10)
    t = list(itertools.combinations(range(5), i))
    for j in t:
        bp=np.zeros(10)
        for J in j:
            bp[J]+=1

        s = 0
        for j in range(n):
            s += (np.dot(dp[j],bp))%2 == l[j]
        if s == n: ans +=1
print(ans)

        

    
    