import itertools
n,m=map(int,input().split())
xs=[list(map(int,input().split()))[1:] for i in range(m)]
p=tuple(map(int,input().split()))
ans=0
for switch in itertools.product(range(2),repeat=n):
  judge=True
  for i in range(m):
    cnt=0
    lst=xs[i]
    for j in lst:
      cnt+=switch[j-1]
    if cnt%2!=p[i]:
      judge=False
      break
  if judge:
    ans+=1

print(ans) import itertools itertools n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m list(map(int,input().split()))[1:] for i in range(m) for i in range(m) i range(m) range m for i in range(m) list(map(int,input().split()))[1:] (map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split 1: 1 xs=[list(map(int,input().split()))[1:] for i in range(m)] xs [list(map(int,input().split()))[1:] for i in range(m)] p=tuple(map(int,input().split())) p tuple(map(int,input().split())) tuple map(int,input().split()) map int input().split() ().split () input split ans=0 ans 0 for switch in itertools.product(range(2),repeat=n):
  judge=True
  for i in range(m):
    cnt=0
    lst=xs[i]
    for j in lst:
      cnt+=switch[j-1]
    if cnt%2!=p[i]:
      judge=False
      break
  if judge:
    ans+=1 switch itertools.product(range(2),repeat=n) itertools.product itertools product range(2) range 2 repeat=n repeat n judge=True judge True for i in range(m):
    cnt=0
    lst=xs[i]
    for j in lst:
      cnt+=switch[j-1]
    if cnt%2!=p[i]:
      judge=False
      break
   i range(m) range m cnt=0 cnt 0 lst=xs[i] lst xs[i] xs i for j in lst:
      cnt+=switch[j-1]
     j lst cnt+=switch[j-1] cnt switch[j-1] switch j-1 j 1 if cnt%2!=p[i]:
      judge=False
      break
   cnt%2!=p[i] cnt%2 cnt 2 p[i] p i judge=False judge False break if judge:
    ans+=1 judge ans+=1 ans 1 print(ans) print ans xs=[list(map(int,input().split()))[1:] for i in range(m)] [list(map(int,input().split()))[1:] for i in range(m)] xs cnt+=switch[j-1] switch[j-1] cnt judge=False False judge judge=True True judge n,m=map(int,input().split()) map(int,input().split()) n ans=0 0 ans m=map(int,input().split()) map(int,input().split()) m cnt=0 0 cnt ans+=1 1 ans p=tuple(map(int,input().split())) tuple(map(int,input().split())) p lst=xs[i] xs[i] lst
import itertools
n,m=map(int,input().split())
xs=[list(map(int,input().split()))[1:] for i in range(m)]
p=tuple(map(int,input().split()))
ans=0
for switch in itertools.product(range(2),repeat=n):
  judge=True
  for i in range(m):
    cnt=0
    lst=xs[i]
    for j in lst:
      cnt+=switch[j-1]
    if cnt%2!=p[i]:
      judge=False
      break
  if judge:
    ans+=1

print(ans)
