N, M = map(int, input().split())
ks = []
for i in range(M):
  tmp = list(map(int, input().split()))
  ks.append(tmp)
p = list(map(int, input().split()))

total = 0
for i in range(int(2**N)):
  bin_val = bin(i)				# 2進数に変換
  bin_val = str(bin_val[2:])	# 先頭２文字を除外し、文字列に変換
  bin_val = bin_val.zfill(N)	# N桁になるように先頭に0を追加
#  print(bin_val)
  
  flag = 1
  for j in range(M):
    count = 0
    k = ks[j][0]
    s = ks[j][1:k+1]
    for l in range(k):      
      if bin_val[s[l]-1] == '1':
        count += 1
    if count % 2 != p[j]:
      flag = 0
      break
  if flag == 1:
    total += 1
print(total)
 N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M ks = [] ks [] for i in range(M):
  tmp = list(map(int, input().split()))
  ks.append(tmp) i range(M) range M tmp = list(map(int, input().split())) tmp list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ks.append(tmp) ks.append ks append tmp p = list(map(int, input().split())) p list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split total = 0 total 0 for i in range(int(2**N)):
  bin_val = bin(i)				# 2進数に変換
  bin_val = str(bin_val[2:])	# 先頭２文字を除外し、文字列に変換
  bin_val = bin_val.zfill(N)	# N桁になるように先頭に0を追加
#  print(bin_val)
  
  flag = 1
  for j in range(M):
    count = 0
    k = ks[j][0]
    s = ks[j][1:k+1]
    for l in range(k):      
      if bin_val[s[l]-1] == '1':
        count += 1
    if count % 2 != p[j]:
      flag = 0
      break
  if flag == 1:
    total += 1 i range(int(2**N)) range int(2**N) int 2**N 2 N bin_val = bin(i) bin_val bin(i) bin i bin_val = str(bin_val[2:]) bin_val str(bin_val[2:]) str bin_val[2:] bin_val 2: 2 bin_val = bin_val.zfill(N) bin_val bin_val.zfill(N) bin_val.zfill bin_val zfill N flag = 1 flag 1 for j in range(M):
    count = 0
    k = ks[j][0]
    s = ks[j][1:k+1]
    for l in range(k):      
      if bin_val[s[l]-1] == '1':
        count += 1
    if count % 2 != p[j]:
      flag = 0
      break
   j range(M) range M count = 0 count 0 k = ks[j][0] k ks[j][0] [j] ks j 0 s = ks[j][1:k+1] s ks[j][1:k+1] [j] ks j 1:k+1 1 k+1 k 1 for l in range(k):      
      if bin_val[s[l]-1] == '1':
        count += 1
     l range(k) range k if bin_val[s[l]-1] == '1':
        count += 1
     bin_val[s[l]-1] == '1' bin_val[s[l]-1] bin_val s[l]-1 s[l] s l 1 '1' count += 1 count 1 if count % 2 != p[j]:
      flag = 0
      break
   count % 2 != p[j] count % 2 count 2 p[j] p j flag = 0 flag 0 break if flag == 1:
    total += 1 flag == 1 flag 1 total += 1 total 1 print(total) print total total = 0 0 total bin_val = str(bin_val[2:]) str(bin_val[2:]) bin_val s = ks[j][1:k+1] ks[j][1:k+1] s M = map(int, input().split()) map(int, input().split()) M N, M = map(int, input().split()) map(int, input().split()) N p = list(map(int, input().split())) list(map(int, input().split())) p flag = 1 1 flag count = 0 0 count bin_val = bin_val.zfill(N) bin_val.zfill(N) bin_val tmp = list(map(int, input().split())) list(map(int, input().split())) tmp bin_val = bin(i) bin(i) bin_val k = ks[j][0] ks[j][0] k ks = [] [] ks flag = 0 0 flag total += 1 1 total count += 1 1 count
N, M = map(int, input().split())
ks = []
for i in range(M):
  tmp = list(map(int, input().split()))
  ks.append(tmp)
p = list(map(int, input().split()))

total = 0
for i in range(int(2**N)):
  bin_val = bin(i)				# 2進数に変換
  bin_val = str(bin_val[2:])	# 先頭２文字を除外し、文字列に変換
  bin_val = bin_val.zfill(N)	# N桁になるように先頭に0を追加
#  print(bin_val)
  
  flag = 1
  for j in range(M):
    count = 0
    k = ks[j][0]
    s = ks[j][1:k+1]
    for l in range(k):      
      if bin_val[s[l]-1] == '1':
        count += 1
    if count % 2 != p[j]:
      flag = 0
      break
  if flag == 1:
    total += 1
print(total)

