n,m = map(int,input().split())
k = []
s = []

for i in range(m):
  k.append(list(map(int,input().split())))
  s.append(k[i].pop(0))
p = list(map(int,input().split()))

light_on = 0
switch_on = 0
ans = 0
for i in range(2**n):
  light_on = 0
  for j in range(m):
    switch_on = 0
    for K in range(s[j]):
      if (i >> k[j][K]-1) &1:
        switch_on += 1
    if switch_on%2 == p[j]:
      light_on += 1
  if light_on == m:
    ans  += 1
print(ans) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m k = [] k [] s = [] s [] for i in range(m):
  k.append(list(map(int,input().split())))
  s.append(k[i].pop(0)) i range(m) range m k.append(list(map(int,input().split()))) k.append k append list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split s.append(k[i].pop(0)) s.append s append k[i].pop(0) [i].pop [i] k i pop 0 p = list(map(int,input().split())) p list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split light_on = 0 light_on 0 switch_on = 0 switch_on 0 ans = 0 ans 0 for i in range(2**n):
  light_on = 0
  for j in range(m):
    switch_on = 0
    for K in range(s[j]):
      if (i >> k[j][K]-1) &1:
        switch_on += 1
    if switch_on%2 == p[j]:
      light_on += 1
  if light_on == m:
    ans  += 1 i range(2**n) range 2**n 2 n light_on = 0 light_on 0 for j in range(m):
    switch_on = 0
    for K in range(s[j]):
      if (i >> k[j][K]-1) &1:
        switch_on += 1
    if switch_on%2 == p[j]:
      light_on += 1
   j range(m) range m switch_on = 0 switch_on 0 for K in range(s[j]):
      if (i >> k[j][K]-1) &1:
        switch_on += 1
     K range(s[j]) range s[j] s j if (i >> k[j][K]-1) &1:
        switch_on += 1
     (i >> k[j][K]-1) &1 i >> k[j][K]-1 i k[j][K]-1 k[j][K] [j] k j K 1 1 switch_on += 1 switch_on 1 if switch_on%2 == p[j]:
      light_on += 1
   switch_on%2 == p[j] switch_on%2 switch_on 2 p[j] p j light_on += 1 light_on 1 if light_on == m:
    ans  += 1 light_on == m light_on m ans  += 1 ans 1 print(ans) print ans p = list(map(int,input().split())) list(map(int,input().split())) p switch_on = 0 0 switch_on switch_on = 0 0 switch_on switch_on += 1 1 switch_on light_on += 1 1 light_on m = map(int,input().split()) map(int,input().split()) m light_on = 0 0 light_on s = [] [] s ans  += 1 1 ans k = [] [] k n,m = map(int,input().split()) map(int,input().split()) n ans = 0 0 ans light_on = 0 0 light_on
n,m = map(int,input().split())
k = []
s = []

for i in range(m):
  k.append(list(map(int,input().split())))
  s.append(k[i].pop(0))
p = list(map(int,input().split()))

light_on = 0
switch_on = 0
ans = 0
for i in range(2**n):
  light_on = 0
  for j in range(m):
    switch_on = 0
    for K in range(s[j]):
      if (i >> k[j][K]-1) &1:
        switch_on += 1
    if switch_on%2 == p[j]:
      light_on += 1
  if light_on == m:
    ans  += 1
print(ans)