### main

a, b, c = gets.strip.split(' ').map{|s| s.to_i}
n = gets.strip.to_i

abc = a + b + c
qcs = abc.times.map{2}

fails = []

n.times do
  i, j, k, r = gets.strip.split(' ').map{|s| s.to_i}
  i -= 1
  j -= 1
  k -= 1

  if r == 1
    qcs[i] = qcs[j] = qcs[k] = 1
  else
    fails << [i, j, k]
  end
end

for fail in fails
  i, j, k = fail

  if qcs[i] == 1 && qcs[j] == 1
    qcs[k] = 0
  end
  if qcs[j] == 1 && qcs[k] == 1
    qcs[i] = 0
  end
  if qcs[k] == 1 && qcs[i] == 1
    qcs[j] = 0
  end
end

for i in (0...abc)
  puts qcs[i]
end