import Data.List ( intersperse ) splitEveryN :: Int -> [a] -> [[a]] splitEveryN n = takeWhile (not . null) . map (take n) . iterate (drop n) myCeiling :: Int -> Int -> Int myCeiling a b = ceiling $ fromIntegral a / fromIntegral b map2 :: (a -> a) -> [a] -> [a] map2 _ [] = [] map2 _ [x] = [x] map2 f (x:y:zs) = (x : (f y) : (map2 f zs)) next :: Char -> Char next 'W' = 'B' next 'B' = 'W' solve :: Int -> Int -> Char -> [String] solve w h c | odd w = splitEveryN w $ intersperse (next c) $ replicate e c | otherwise = map2 reverse $ splitEveryN h $ concat $ replicate d ([c] ++ [next c]) where d = (w * h) `div` 2 e = myCeiling (w + h) 2 main :: IO () main = do [a, b, s] <- words <$> getLine let w = (read :: String -> Int) a h = (read :: String -> Int) b [c] = s z = solve w h c putStr $ unlines z