from collections import deque

N, M = map(int, input().split())
k = deque()
s = deque()
for _ in range(M):
    inp = list(map(int, input().split()))
    k.append(inp[0])
    s.append(inp[1:])
p = list(map(int, input().split()))

ans = 0
for i in range(1<<N):
  all_on = True
  for m_i in range(M):
    swon = 0
    for s_i in s[m_i]:
      if i>>(s_i-1)&1:
        swon += 1
    
    if swon%2 != p[m_i]: #電球がOFFだったら
      all_on = False
      break
  
  if all_on: ans += 1

print(ans) from collections import deque N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M k = deque() k deque() deque s = deque() s deque() deque for _ in range(M):
    inp = list(map(int, input().split()))
    k.append(inp[0])
    s.append(inp[1:]) _ range(M) range M inp = list(map(int, input().split())) inp list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split k.append(inp[0]) k.append k append inp[0] inp 0 s.append(inp[1:]) s.append s append inp[1:] inp 1: 1 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 i in range(1<<N):
  all_on = True
  for m_i in range(M):
    swon = 0
    for s_i in s[m_i]:
      if i>>(s_i-1)&1:
        swon += 1
    
    if swon%2 != p[m_i]: #電球がOFFだったら
      all_on = False
      break
  
  if all_on: ans += 1 i range(1<<N) range 1<<N 1 N all_on = True all_on True for m_i in range(M):
    swon = 0
    for s_i in s[m_i]:
      if i>>(s_i-1)&1:
        swon += 1
    
    if swon%2 != p[m_i]: #電球がOFFだったら
      all_on = False
      break
  
   m_i range(M) range M swon = 0 swon 0 for s_i in s[m_i]:
      if i>>(s_i-1)&1:
        swon += 1
    
     s_i s[m_i] s m_i if i>>(s_i-1)&1:
        swon += 1
    
     i>>(s_i-1)&1 i>>(s_i-1) i s_i-1 s_i 1 1 swon += 1 swon 1 if swon%2 != p[m_i]: #電球がOFFだったら
      all_on = False
      break
  
   swon%2 != p[m_i] swon%2 swon 2 p[m_i] p m_i all_on = False all_on False break if all_on: ans += all_on print(ans) print ans all_on = False False all_on inp = list(map(int, input().split())) list(map(int, input().split())) inp k = deque() deque() k swon = 0 0 swon ans = 0 0 ans M = map(int, input().split()) map(int, input().split()) M all_on = True True all_on swon += 1 1 swon N, M = map(int, input().split()) map(int, input().split()) N p = list(map(int, input().split())) list(map(int, input().split())) p s = deque() deque() s
from collections import deque

N, M = map(int, input().split())
k = deque()
s = deque()
for _ in range(M):
    inp = list(map(int, input().split()))
    k.append(inp[0])
    s.append(inp[1:])
p = list(map(int, input().split()))

ans = 0
for i in range(1<<N):
  all_on = True
  for m_i in range(M):
    swon = 0
    for s_i in s[m_i]:
      if i>>(s_i-1)&1:
        swon += 1
    
    if swon%2 != p[m_i]: #電球がOFFだったら
      all_on = False
      break
  
  if all_on: ans += 1

print(ans)
