import Control.Applicative import Control.Monad import Data.List import Debug.Trace check :: String -> String check str = if check_sub 0 0 0 str then "possible" else "impossible" where check_sub r g b "" = r == 0 && g == 0 check_sub r g w (x:xs) | x == 'R' = check_sub (r+1) g w xs | x == 'G' = if r > 0 then check_sub (r-1) (g+1) w xs else False | x == 'W' && g > 0 = check_sub r (g-1) (w+1) xs | x == 'W' && w > 0 = check_sub r g (w+1) xs | otherwise = False main = do mapM_ putStrLn =<< map (check.reverse) <$> drop 1 <$> lines <$> getContents