프로그램 명: boi_gat
제한시간: 1 초

After many years of working as a software developer you have decided to try something entirely difierent, and started looking at random job ofiers. The one that really caught your eye was a job in fish farming (a form of aquaculture). ’Cool!’, you thought, and besides, fish are nice creatures. So you applied, got accepted, and today is your first day at work.

Your boss has already assigned you a task. You have to isolate one water reservoir from another. After looking at some schemes you’ve been given, here’s what you’ve figured out.

The two water reservoirs are connected by several channels. Each channel has two gates. The channel is open when both gates are open, and is closed otherwise. The gates are controlled using switches. The same switch may operate several gates, but each gate is operated by exactly one switch. It is possible that both gates on a channel are controlled by the same switch and that a switch controls no gates.

The switch may operate the gate in one of two ways:

After playing a bit with the switches you suddenly realize that your programming experience will come in very handy.

Write a program that, given the configuration of gates and switches, determines whether it is possible to close all channels, and if it is, then finds a state of every switch in one such valid configuration.

입력

출력

If it is possible to close all the channels, the standard output should contain m lines. Line i should contain 0 , if switch i should be off, and 1 if switch i should be on. If there are many possible solutions, your program may output any of them.

If it is impossible to close all channels, your program should output one line, containing a single word IMPOSSIBLE.

입출력 예

입력

3 2
1 0 2 1
1 0 2 0
1 1 2 1

출력

0
1

입력

2 1
1 0 1 0
1 1 1 1

출력

IMPOSSIBLE

The first example corresponds to the picture from the task description
출처:BOI 2008 day1 3/7

[질/답] [제출 현황] [푼 후(0)]
[ 채 점 ] [홈으로]  [뒤 로]