fun readInt () = valOf (TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn) fun readChar () = valOf (TextIO.scanStream Char.scan TextIO.stdIn) val () = let val w = readInt () val h = readInt () val c = readChar () fun printAns () = let fun makeLine 0 _ = [] | makeLine n ch = if ch = #"B" then #"W" :: makeLine (n - 1) #"W" else #"B" :: makeLine (n - 1) #"B" fun makeLines 0 _ = ignore () | makeLines n ch = if ch = #"B" then ( print (String.implode (List.rev (makeLine w #"W")) ^ "\n"); makeLines (n - 1) #"W" ) else ( print (String.implode (List.rev (makeLine w #"B")) ^ "\n"); makeLines (n - 1) #"B" ) in makeLines h c end in printAns () end