def area n
  as = (n-1).times.map { gets.to_i }
  as << 360 - as.inject(0, :+)
  as.map {|a| Math.sin(2 * Math::PI * a / 360) }.inject(0, :+)
end

loop do
  m = gets.to_i
  break if m.zero?
  x = area(m)
  y = area(gets.to_i)
  p (x - y).abs < 1e-8 ? 0 : x > y ? 1 : 2
end