eolymp
bolt
Try our new interface for solving problems
Problems

Mortal Kombat

Mortal Kombat

Once every generation, there is a tournament known as Mortal Kombat, which was designed by the Elder Gods for the main purpose to save Earthrealm from the dark forces of Outworld. If the forces of Outworld win the tournament ten consecutive times, the Emperor will be able to invade and conquer Earthrealm. Thus far, Outworld has won nine straight victories, making the upcoming tournament the tenth, and possibly final one, for the Earthrealm. There are \textbf{N} monsters and \textbf{M} best human fighters participating in the Mortal Kombat. According to the tournament rules, each monster should fight one of the humans (different monsters should fight different humans). If at least one monster wins, the Eathrealm will be conquered by the Emperor of the Outworld. However, the humans can choose the competitors and the order of battles. The thunder god Raiden, protector of the Earthrealm, should choose the fighters in such a way that all Earth warriors will win their battles. For each monster and each Earth warrior it is known whether the Earth warrior can win the monster. First of all, the fighters for the first battle should be chosen. For example, suppose that Liu Kang wants to fight Goro, but he is the only warrior able to defeat Shang Tsung, while Goro can be defeated by other warriors, such as Johnny Cage. So, even if Liu Kang will defeat Goro in the first battle, it will inevitably lead to the conquest of the Earth, because later Shang Tsung will defeat his opponent. This means that the pair Liu Kang vs. Goro should not be selected for the first fight. Find out which pairs cannot be chosen by Raiden if he wants to save the freedom of humanity. \InputFile The first line contains integers \textbf{N} and \textbf{M}. \textbf{1} ≤ \textbf{N} ≤ \textbf{300}, \textbf{N} ≤ \textbf{M} ≤ \textbf{1500}. Next lines contain the binary matrix \textbf{A} with \textbf{N }rows and \textbf{M} columns. \textbf{A_ij = 1} if and only if \textbf{j}-th Earth warrior can defeat \textbf{i}-th monster. \OutputFile Output matrix \textbf{B} with \textbf{N} rows and \textbf{M} columns. \textbf{B_ij} should be equal to one if the first battle cannot be held between \textbf{i}-th monster and \textbf{j}-th human, and zero otherwise.
Time limit 1 second
Memory limit 64 MiB
Input example #1
4 4
1111
1000
1111
1111
Output example #1
1000
0111
1000
1000
Author Magaz Asanov, Alexander Ipatov
Source Ural SU Contest. Petrozavodsk Summer Session, August 2008