import math
N, M = map(int, input().split())
switch = [0] * N
pattern = 2 ** N
ans = 0
for i in range(M):
  temp = input().split()[1:]
  for j in temp:
    switch[int(j) - 1] += (1 << i )
  
p = list(map(int, input().split()))
pbin = 0
temp = 1
for i in p:
  pbin += i * temp
  temp *= 2

for i in range(pattern):
  temp = 0
  j = 0
  while i > 0:
    if i & 1 == 1 :
      temp = temp ^ switch[j]
    j += 1
    i = i >> 1
  if pbin == temp:
    ans += 1
print(ans) import math math N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M switch = [0] * N switch [0] * N [0] 0 N pattern = 2 ** N pattern 2 ** N 2 N ans = 0 ans 0 for i in range(M):
  temp = input().split()[1:]
  for j in temp:
    switch[int(j) - 1] += (1 << i )
   i range(M) range M temp = input().split()[1:] temp input().split()[1:] ().split() ().split () input split 1: 1 for j in temp:
    switch[int(j) - 1] += (1 << i )
   j temp switch[int(j) - 1] += (1 << i ) switch[int(j) - 1] switch int(j) - 1 int(j) int j 1 1 << i 1 i p = list(map(int, input().split())) p list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split pbin = 0 pbin 0 temp = 1 temp 1 for i in p:
  pbin += i * temp
  temp *= 2 i p pbin += i * temp pbin i * temp i temp temp *= 2 temp 2 for i in range(pattern):
  temp = 0
  j = 0
  while i > 0:
    if i & 1 == 1 :
      temp = temp ^ switch[j]
    j += 1
    i = i >> 1
  if pbin == temp:
    ans += 1 i range(pattern) range pattern temp = 0 temp 0 j = 0 j 0 while i > 0:
    if i & 1 == 1 :
      temp = temp ^ switch[j]
    j += 1
    i = i >> 1
   i > 0 i 0 if i & 1 == 1 :
      temp = temp ^ switch[j]
     i & 1 == 1 i & 1 i 1 1 temp = temp ^ switch[j] temp temp ^ switch[j] temp switch[j] switch j j += 1 j 1 i = i >> 1 i i >> 1 i 1 if pbin == temp:
    ans += 1 pbin == temp pbin temp ans += 1 ans 1 print(ans) print ans temp = temp ^ switch[j] temp ^ switch[j] temp j += 1 1 j pbin += i * temp i * temp pbin j = 0 0 j temp = input().split()[1:] input().split()[1:] temp p = list(map(int, input().split())) list(map(int, input().split())) p i = i >> 1 i >> 1 i switch = [0] * N [0] * N switch temp *= 2 2 temp N, M = map(int, input().split()) map(int, input().split()) N temp = 1 1 temp pattern = 2 ** N 2 ** N pattern pbin = 0 0 pbin M = map(int, input().split()) map(int, input().split()) M ans = 0 0 ans temp = 0 0 temp ans += 1 1 ans
import math
N, M = map(int, input().split())
switch = [0] * N
pattern = 2 ** N
ans = 0
for i in range(M):
  temp = input().split()[1:]
  for j in temp:
    switch[int(j) - 1] += (1 << i )
  
p = list(map(int, input().split()))
pbin = 0
temp = 1
for i in p:
  pbin += i * temp
  temp *= 2

for i in range(pattern):
  temp = 0
  j = 0
  while i > 0:
    if i & 1 == 1 :
      temp = temp ^ switch[j]
    j += 1
    i = i >> 1
  if pbin == temp:
    ans += 1
print(ans)
