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