query :: Int -> Int -> String query h w | odd h == odd w = "white" | otherwise = "black" main = do [h,w] <- map read . words <$> getLine getLine sks <- map ((\[s,k]-> (s, read k)) . words) . lines <$> getContents putStrLn $ (ichimatsu h w sks) ichimatsu :: Int -> Int -> [(String,Int)] -> String ichimatsu h w sks = uncurry query $ foldr (sim h w) (0,0) sks sim :: Int -> Int -> (String,Int) -> (Int,Int) -> (Int,Int) sim h w ("R",k) (h',w') | k/=h' = (h',w') | w'==0 = (h',w-1) | otherwise = (h',w'-1) sim h w ("C",k) (h',w') | k/=w' = (h',w') | h'==0 = (h-1,w') | otherwise = (h'-1,w')