n = gets.to_i n.times do lines = [] s = gets.chomp.chars.reverse s.each do |c| if c == 'R' lines << 0 elsif c == 'G' g = lines.index(0) if g lines[g] = 1 else lines << -1 break end else w = lines.index(1) || lines.index(2) if w lines[w] = 2 if lines[w] == 1 else lines << -1 break; end end end puts lines.all? {|v| v == 2 } ? "possible" : "impossible" end