import itertools

n, m = map(int, input().split())
switches = []
for i in range(m):
  switches.append(input())
lights = list(map(int, input().split()))

switch = [0, 1]
lists = list(itertools.product(switch, repeat=n))
count = 0
for l in lists:
  for i in range(m):
    on = 0
    switches_list = list(map(int, switches[i].split()))
    switch_num = lights[i]
    repeat_num = switches_list[0] + 1
    for j in range(1, repeat_num):
      switch_pos = switches_list[j] - 1
      on += l[switch_pos]
    if on % 2 != switch_num:
      break
    if i == m - 1:
      count += 1
print(count) import itertools itertools n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m switches = [] switches [] for i in range(m):
  switches.append(input()) i range(m) range m switches.append(input()) switches.append switches append input() input lights = list(map(int, input().split())) lights list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split switch = [0, 1] switch [0, 1] 0 1 lists = list(itertools.product(switch, repeat=n)) lists list(itertools.product(switch, repeat=n)) list itertools.product(switch, repeat=n) itertools.product itertools product switch repeat=n repeat n count = 0 count 0 for l in lists:
  for i in range(m):
    on = 0
    switches_list = list(map(int, switches[i].split()))
    switch_num = lights[i]
    repeat_num = switches_list[0] + 1
    for j in range(1, repeat_num):
      switch_pos = switches_list[j] - 1
      on += l[switch_pos]
    if on % 2 != switch_num:
      break
    if i == m - 1:
      count += 1 l lists for i in range(m):
    on = 0
    switches_list = list(map(int, switches[i].split()))
    switch_num = lights[i]
    repeat_num = switches_list[0] + 1
    for j in range(1, repeat_num):
      switch_pos = switches_list[j] - 1
      on += l[switch_pos]
    if on % 2 != switch_num:
      break
    if i == m - 1:
      count += 1 i range(m) range m on = 0 on 0 switches_list = list(map(int, switches[i].split())) switches_list list(map(int, switches[i].split())) list map(int, switches[i].split()) map int switches[i].split() [i].split [i] switches i split switch_num = lights[i] switch_num lights[i] lights i repeat_num = switches_list[0] + 1 repeat_num switches_list[0] + 1 switches_list[0] switches_list 0 1 for j in range(1, repeat_num):
      switch_pos = switches_list[j] - 1
      on += l[switch_pos]
     j range(1, repeat_num) range 1 repeat_num switch_pos = switches_list[j] - 1 switch_pos switches_list[j] - 1 switches_list[j] switches_list j 1 on += l[switch_pos] on l[switch_pos] l switch_pos if on % 2 != switch_num:
      break
     on % 2 != switch_num on % 2 on 2 switch_num break if i == m - 1:
      count += 1 i == m - 1 i m - 1 m 1 count += 1 count 1 print(count) print count switches = [] [] switches repeat_num = switches_list[0] + 1 switches_list[0] + 1 repeat_num on = 0 0 on switch = [0, 1] [0, 1] switch switch_pos = switches_list[j] - 1 switches_list[j] - 1 switch_pos n, m = map(int, input().split()) map(int, input().split()) n switch_num = lights[i] lights[i] switch_num switches_list = list(map(int, switches[i].split())) list(map(int, switches[i].split())) switches_list count = 0 0 count count += 1 1 count on += l[switch_pos] l[switch_pos] on lights = list(map(int, input().split())) list(map(int, input().split())) lights m = map(int, input().split()) map(int, input().split()) m lists = list(itertools.product(switch, repeat=n)) list(itertools.product(switch, repeat=n)) lists
import itertools

n, m = map(int, input().split())
switches = []
for i in range(m):
  switches.append(input())
lights = list(map(int, input().split()))

switch = [0, 1]
lists = list(itertools.product(switch, repeat=n))
count = 0
for l in lists:
  for i in range(m):
    on = 0
    switches_list = list(map(int, switches[i].split()))
    switch_num = lights[i]
    repeat_num = switches_list[0] + 1
    for j in range(1, repeat_num):
      switch_pos = switches_list[j] - 1
      on += l[switch_pos]
    if on % 2 != switch_num:
      break
    if i == m - 1:
      count += 1
print(count)