ENG  RUSTimus Online Judge
Online Judge
Online contests
About Online Judge
Frequently asked questions
Site news
Problem set
Submit solution
Judge status
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests

1968. Glass Pyramid

Time limit: 1.0 second
Memory limit: 64 MB
Problem illustration
Vova is a skyscraper fan. When he arrives in a city that has any skyscrapers, he always tries to get to the observation deck in the highest skyscraper to make several shots from there. This time is no exception. As soon as Vova arrived in Hong Kong, right after checking in a hotel, he got to the International Commercial Center, a 118-floor building that was built a couple of years ago.
Before the main entrance into the International Commercial Center there is a pyramid of large glass blocks. Each block has the shape of a one meter height rectangular parallelepiped with a 2 × 2 meter square base. The pyramid's lowest layer is m × n meter large. The second layer is (m − 2) × (n − 2) meter large and is located so that the vertices of each block's lower side coincided with the centers of the upper sides of the previous layer. The third and the next layers are constructed similarly. The upper layer consists of a single row of blocks (specifically, at m = n it consists of one block). Some pyramid blocks are made of colorless glass and the other blocks are made of reddish glass.
When Vova got to the observation platform, located at the skyscraper's 100-th floor, he saw the pyramid from there as a rectangular field, divided into 1 × 1 meter cells. The reddish hue of each cell hinted the number of reddish glass blocks that laid on this cell. Vova took the photo of the pyramid from above and now he wants you to take a look at this photo and find out which pyramid blocks are made of reddish glass and which ones are made of colorless glass. Vova also says that there is no reddish block lying exactly above a colorless block.


The first line contains integers m and n that are sizes of the pyramid's base (2 ≤ m, n ≤ 40; m and n are even). Then m lines follow, each of them contains n non-negative integers, describing the photo Vova took. Each integer shows the number of reddish blocks lying above the corresponding cell. It is guaranteed that the input gives some possible arrangement of blocks in the pyramid.


Print the description of the layers, from the lowest one to the highest one. To print information about the i-th layer, use ki lines each containing li characters (k1 = m/2; l1 = n/2; ki = ki − 1 − 1; li = li − 1 − 1). Character “R” represents a reddish block, “W” represents a colorless block. Each next layer is separated from the previous one by an empty line. If there are multiple solutions, you can print any of them.


4 6
0 0 1 1 0 0
0 0 1 2 1 0
0 0 0 1 2 1
0 0 0 0 1 1

Problem Source: Open Ural FU Personal Contest 2013