def solver():
    S = input()
    G = 0
    W = 0
    _g = S.count("G")
    _r = S.count("R")
    _w = S.count("W")
    if _g != _r:
        return "impossible"
    if _r > _w:
        return "impossible"
    line = _r
    for i in S:
        if i == "G":
            G += 1
            if G > W:
                return "impossible"
            line -= 1
        if i == "R":
            if G == 0:
                return "impossible"
            G -= 1
        if i == "W":
            W += 1
            if line <= 0:
                return "impossible"
    if G > 0:
        return "impossible"
    return "possible"

global res
T = int(input())
ans = [solver() for i in range(T)]
for i in ans:
    print(ans)