n = gets.to_i n.times do lines = [0,0,0,0] s = gets.chomp.chars.reverse s.each do |c| if c == 'R' lines[0] += 1 elsif c == 'G' if lines[0] > 0 lines[0] -= 1 lines[1] += 1 else lines[3] = 1 break end else if lines[1] > 0 lines[1] -= 1 lines[2] += 1 elsif lines[2] > 0 else lines[3] = 1 break; end end end puts [0,1,3].all? {|i| lines[i] == 0 } ? "possible" : "impossible" end