### main

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

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

tests = []

n.times do
  tests << gets.strip.split(' ').map{|s| s.to_i}
end

tests.sort!{|a, b| b[3] <=> a[3]}
#p tests

for test in tests
  i, j, k, r = test

  if r == 1
    qcs[i] = qcs[j] = qcs[k] = 1
  else
    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
end

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