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 f s 0 then "possible" else "impossible"