Zero AAMP Currents
시간 제한2초메모리 제한256 MB
모든 사이클을 따라 전류의 합이 0이 되도록 각 유향 간선에 [-1000, 1000] 범위의 0이 아닌 정수 전류를 배정한다.
문제
Thomas Edison stumbled upon an alien electrical device that appears to break known laws of physics! The device consists of batteries connected by unidirectional wires, which we will represent as vertices and edges that form a graph. The -th wire is directed from battery to battery , . Let denote such a wire.
To make this device work, Thomas must assign a current strength to each wire such that this assignment results in a successful configuration. For a configuration to be successful, two conditions must be met:
- All current strength values are non-zero integers in the range AAMP (Alien Amperes).
- For every cycle found in this device, the sum of AAMP values from all wires in it must be . A cycle is a sequence of edges (wires) , , ,, . If edges and both exist, they also form a cycle – the wires are unidirectional.
Help him with this task.
입력
The first line contains two integers and – the number of batteries and the number of wires in the device, respectively. Next, lines contain two integers each and , which mean that the -th wire goes from battery to .
출력
Print lines containing one number each: the -th number should be the current strength of -th wire (in AAMP). Each number should be non-zero and in the range of . If multiple answers exist, you may print any one of them.
제한
- ,
힌트
Note that there can be multiple wires from battery to . Also note that wire with strength AAMP is not the same as with strength . As mentioned before, wires are unidirectional and can have a negative current strength - that’s one of the mysteries of this device ...