while n = gets.to_i break if n == -1 n.times do gets.split.map(&:to_i) end STDOUT.puts("S") STDOUT.flush end