N,M=map(int,input().split())
k=[0]*M
s=[0]*M
for i in range(M):
    ks=list(map(int,input().split()))
    k[i]=ks[0]
    s[i] = [n-1 for n in ks[1:k[i]+1]]
p=list(map(int,input().split()))
ok=0

#スイッチのon/off
def dfs(A):
    global ok
    # 終端条件 --- N 重ループまで回したら処理して打ち切り
    if len(A) == N:
        ok+=jg(A)
        return
    for v in range(2):
        A.append(v)
        dfs(A)
        A.pop()

#判定
def jg(A):
    for i in range(M):
        ans=0
        for j in range(k[i]):
            ans+=A[j]
        if ans % 2 != p[i]:
            return 0
    return 1

dfs([])
print(ok)