St = Win = 1
Sc = Lose = 2
Pa = Draw = 3
NoWin = -1 

def getWinHand hand
  st = hand.include? St
  sc = hand.include? Sc
  pa = hand.include? Pa
  if (st && sc && pa) || (st && !sc && !pa) || (!st && sc && !pa) || (!st && !sc && pa)
    NoWin
  elsif st && pa
    Pa
  elsif st && sc
    St
  elsif sc && pa
    Sc
  end
end

def getResult hand, winHand
  if winHand == NoWin
    Draw
  elsif hand == winHand
    Win
  else
    Lose
  end
end

def showResult hand
  winHand = getWinHand hand
  hand.each do |h|
    p getResult(h, winHand)
  end
end


until (n = $stdin.gets.to_i) == 0
  hand = [n]
  4.times do
    hand << $stdin.gets.to_i
  end
  showResult(hand)
end