from itertools import product

N,M=map(int,input().split())
S = []
for i in range(M):
  k,*s = map(int,input().split())
  S.append(s)
P=list(map(int,input().split()))

ans=0
for p in product(range(2),repeat=N):
  cnt1 = 0
  for i in range(M):
    cnt2 = 0
    for j in range(len(S[i])):
      if p[S[i][j]-1]==1:
        cnt2 += 1
    if cnt2 % 2== P[i]:
      cnt1 += 1
  if cnt1 == M:
    ans += 1

print(ans) from itertools import product N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M S = [] S [] for i in range(M):
  k,*s = map(int,input().split())
  S.append(s) i range(M) range M k,*s = map(int,input().split()) k map(int,input().split()) map int input().split() ().split () input split *s s S.append(s) S.append S append s P=list(map(int,input().split())) P list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split ans=0 ans 0 for p in product(range(2),repeat=N):
  cnt1 = 0
  for i in range(M):
    cnt2 = 0
    for j in range(len(S[i])):
      if p[S[i][j]-1]==1:
        cnt2 += 1
    if cnt2 % 2== P[i]:
      cnt1 += 1
  if cnt1 == M:
    ans += 1 p product(range(2),repeat=N) product range(2) range 2 repeat=N repeat N cnt1 = 0 cnt1 0 for i in range(M):
    cnt2 = 0
    for j in range(len(S[i])):
      if p[S[i][j]-1]==1:
        cnt2 += 1
    if cnt2 % 2== P[i]:
      cnt1 += 1
   i range(M) range M cnt2 = 0 cnt2 0 for j in range(len(S[i])):
      if p[S[i][j]-1]==1:
        cnt2 += 1
     j range(len(S[i])) range len(S[i]) len S[i] S i if p[S[i][j]-1]==1:
        cnt2 += 1
     p[S[i][j]-1]==1 p[S[i][j]-1] p S[i][j]-1 S[i][j] [i] S i j 1 1 cnt2 += 1 cnt2 1 if cnt2 % 2== P[i]:
      cnt1 += 1
   cnt2 % 2== P[i] cnt2 % 2 cnt2 2 P[i] P i cnt1 += 1 cnt1 1 if cnt1 == M:
    ans += 1 cnt1 == M cnt1 M ans += 1 ans 1 print(ans) print ans cnt2 = 0 0 cnt2 cnt2 += 1 1 cnt2 N,M=map(int,input().split()) map(int,input().split()) N P=list(map(int,input().split())) list(map(int,input().split())) P M=map(int,input().split()) map(int,input().split()) M cnt1 = 0 0 cnt1 cnt1 += 1 1 cnt1 k,*s = map(int,input().split()) map(int,input().split()) k S = [] [] S ans=0 0 ans ans += 1 1 ans
from itertools import product

N,M=map(int,input().split())
S = []
for i in range(M):
  k,*s = map(int,input().split())
  S.append(s)
P=list(map(int,input().split()))

ans=0
for p in product(range(2),repeat=N):
  cnt1 = 0
  for i in range(M):
    cnt2 = 0
    for j in range(len(S[i])):
      if p[S[i][j]-1]==1:
        cnt2 += 1
    if cnt2 % 2== P[i]:
      cnt1 += 1
  if cnt1 == M:
    ans += 1

print(ans)