import std.stdio, std.array, std.conv, std.string, std.algorithm; bool check(string s) { int cnt = 0; int wcnt = 0; bool exist = false; if (s[$-1] != 'R') { return false; } foreach(char c; s) { if (c == 'W') { wcnt = 1; } else if (c == 'G') { cnt++; } else if (c == 'R') { if (! (wcnt == 1 && cnt > 1)) { return false; } cnt--; wcnt = 0; 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"); } } }