import sys
from collections import defaultdict
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N,M = MI()
S = [LI() for _ in range(M)]
P = LI()

ans = 0
for i in range(1 << N):
    d = defaultdict(int)
    for j in range(N):
        if (i >> j) & 1:
            d[j] = 1
    for k in range(M):
        if sum(d[l-1] for l in S[k][1:]) % 2 != P[k]:
            break
    else:
        ans += 1

print(ans) import sys sys from collections import defaultdict def MI(): return map(int,sys.stdin.readline().rstrip().split()) MI def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり LI N,M = MI() N MI() MI M LI() for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) LI() LI S = [LI() for _ in range(M)] S [LI() for _ in range(M)] P = LI() P LI() LI ans = 0 ans 0 for i in range(1 << N):
    d = defaultdict(int)
    for j in range(N):
        if (i >> j) & 1:
            d[j] = 1
    for k in range(M):
        if sum(d[l-1] for l in S[k][1:]) % 2 != P[k]:
            break
    else:
        ans += 1 i range(1 << N) range 1 << N 1 N d = defaultdict(int) d defaultdict(int) defaultdict int for j in range(N):
        if (i >> j) & 1:
            d[j] = 1
     j range(N) range N if (i >> j) & 1:
            d[j] = 1
     (i >> j) & 1 i >> j i j 1 d[j] = 1 d[j] d j 1 for k in range(M):
        if sum(d[l-1] for l in S[k][1:]) % 2 != P[k]:
            break
    else:
        ans += 1 k range(M) range M if sum(d[l-1] for l in S[k][1:]) % 2 != P[k]:
            break
     sum(d[l-1] for l in S[k][1:]) % 2 != P[k] sum(d[l-1] for l in S[k][1:]) % 2 sum(d[l-1] for l in S[k][1:]) sum d[l-1] d l-1 l 1 2 P[k] P k break ans += 1 ans 1 print(ans) print ans def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり LI N,M = MI() MI() N def MI(): return map(int,sys.stdin.readline().rstrip().split()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) MI ans = 0 0 ans S = [LI() for _ in range(M)] [LI() for _ in range(M)] S P = LI() LI() P ans += 1 1 ans d = defaultdict(int) defaultdict(int) d M = MI() MI() M
import sys
from collections import defaultdict
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N,M = MI()
S = [LI() for _ in range(M)]
P = LI()

ans = 0
for i in range(1 << N):
    d = defaultdict(int)
    for j in range(N):
        if (i >> j) & 1:
            d[j] = 1
    for k in range(M):
        if sum(d[l-1] for l in S[k][1:]) % 2 != P[k]:
            break
    else:
        ans += 1

print(ans)
