# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
end

nn = inputs[0][0]
print "nn:" if $debugFlag
pd nn
consts = []
for i in 1..inputs.size-2 do
  consts << [inputs[i][1..-1], inputs[-1][i-1]]
end

pd consts

cnt = 0
for i in 0..2**nn-1 do
  pd "i=#{i}"
  flag = true
  for j in 0..consts.size-1 do
    pd "j=#{j}"
    tmp = 0
    tmpstr = ""
    consts[j][0].size.times do |k|
      tmp += i[consts[j][0][k]-1]
      tmpstr += i[consts[j][0][k]].to_s + "+"
    end
    pd tmpstr
    if (tmp % 2) != consts[j][1]
      flag = false
      break
    end
  end
  if flag == true
    pd "i=#{i}: true"
    cnt += 1
  else
    pd "i=#{i}: false"    
  end
end

puts cnt
