loop do
  rps = Array.new(5)
  rps[0] = gets.to_i
  break if rps[0].zero?
  1.upto(4) do |i|
    rps[i] = gets.to_i
  end
  rpsu = rps.uniq
  if rpsu.size == 2
    x, y = rpsu.sort
    rps.each do |n|
      if (y-x) == 1
        puts n == x ? 1 : 2
      else
        puts n == x ? 2 : 1
      end
    end
  else
    5.times { puts 3 }
  end
end