import sys
from itertools import combinations


N, M = [int(n) for n in sys.stdin.readline().strip().split()]

ks = []
ss = []
ss_all = []
for i in range(M):
  tmp = [int(n) for n in sys.stdin.readline().strip().split()]
  ks.append(tmp[0])
  ss.append(tmp[1:])
  ss_all += tmp[1:]
  
ps = [int(n) for n in sys.stdin.readline().strip().split()]

ss_set = set(ss_all)

cnt = 0
for i in range(len(ss_set)):
  for comb in combinations(ss_set, i+1):
    flag = True
    for i_ramp, s in enumerate(ss):
      if not sum([1 for se in s if se in comb])%2==ps[i_ramp]:
        flag = False
        break
    if flag:
      cnt += 1

cnt *= 2**(N - len(ss_set))
print(cnt)