Mirko has just installed a brand new drawing program. The program supports
The upper left cell of the canvas has coordinates
Mirko's favourite pastime is drawing rectangular checkerboard patterns using the command PAINT c x1 y1 x2 y2
, where
The upper left cell of the rectangle will be painted in the chosen colour, while the rest are determined by the checkerboard pattern. Cells that are not painted over by the chosen colour will retain their previous colour. For example, a white canvas painted over by a red checkerboard pattern will look like this:
Mirko has recently discovered two additional commands. He can save his painting at any time using the creatively named command SAVE
, and load it again later using the command LOAD x
, where
Unfortunately, the program has crashed and Mirko's painting is lost forever. Luckily, Mirko has saved a log of all used commands. Can you help Mirko by reconstructing the lost painting?
Input Specification
The first line of input contains three positive integers,
Each of the following
Output Specification
Output must consist of
Sample Input 1
4 3 2
PAINT 2 0 0 3 3
PAINT 3 0 3 3 3
Sample Output 1
2 1 2 3
1 2 1 2
2 1 2 3
1 2 1 2
Sample Input 2
3 3 4
PAINT 3 0 0 1 1
SAVE
PAINT 2 1 1 2 2
LOAD 1
Sample Output 2
3 1 1
1 3 1
1 1 1
Sample Input 3
3 4 7
PAINT 2 0 0 1 1
SAVE
PAINT 3 1 1 2 2
SAVE
PAINT 4 0 2 0 2
LOAD 2
PAINT 4 2 0 2 0
Sample Output 3
2 1 1
1 3 1
4 1 3
Comments