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

Ural Championship 2005 Round II

About     Problems     Submit solution     Judge status     Standings
Contest is over

D. Halftones

Time limit: 1.0 second
Memory limit: 64 MB
Ivan Pyatochnikov loves to tinker with electronics. That's why he has a great authority with his friends. Indeed, he can repair whatever piece of hardware you give him. He will deal with any incorrectly configured program. And he will even fix bugs in your code.
Today is Ivan's birthday, and his buddies are preparing a really cool present for him — namely, a genuine shamanic tambourine. Yes, a tambourine. After all, no real geek can live without such an indispensable thing.
Having bought the tambourine and read the manual, Ivan's friends have discovered that a tambourine only becomes effective when there is a picture of owner printed on it, along with some special magical signs. Now the friends are rather depressed, because they only have a dot matrix printer and a file containing the grayscale photo of Ivan. Clearly, any image to be printed on a dot matrix printer shall be monochrome (i.e. shall contain black and white pixels only). Ivan's photo consists of different shades of gray, and friends are afraid that the printout won't resemble the original photo closely enough for the tambourine to work.
You have agreed to help Ivan's buddies prepare the present.


The first line contains two integers N and M (75 ≤ N, M ≤ 300) — the dimensions of the image. N following lines, each line containing M integers ranging from 0 to 255, define the image itself.


The output shall contain the monochrome image in the form of N lines with M numbers on each line. Each number must be either 0 or 255. For the resulting monochrome image to resemble the original, the following condition must be satisfied for each i and j:
Problem illustration
where A[i, j] is the brightness of the original image pixel (i, j) and B[i, j] is the corresponding monochrome image pixel brightness.


3 3
255 255 0
0 0 255
254 0 253
255 255 0
0 0 255
255 0 255


Note that this example is incorrect, because N and M are out of the defined range. Nevertheless, the example shows the correct format of input and output.
Problem Author: Eugeniy Krokhalev (idea by Pavel Atnashev)
Problem Source: IX Collegiate Students Urals Programming Contest. Yekaterinburg, April 19-24, 2005
To submit the solution for this problem go to the Problem set: 1363. Halftones