import std.stdio, std.array, std.conv, std.string, std.algorithm; bool check(string s) { int cnt = 0; bool exist = false; foreach(char c; s) { if (c == 'G') { cnt++; } else if (c == 'R') { cnt--; exist = true; } if (cnt < 0) { return false; } } return exist; } void main() { int n = readln.chomp.to!int; foreach (i; 0..n) { bool possible = check(readln.chomp); if (possible) { writeln("possible"); } else { writeln("impossible"); } } }