import Control.Monad main = do n <- readLn replicateM n $ do s <- getLine let f [] g = g == 0 f (x:xs) g | x == 'W' = f xs g | x == 'G' = f xs (g+1) | g > 0 = f xs (g-1) | otherwise = False in putStrLn $ if length s < 3 || not (f s 0) then "impossible" else "possible"