Zero AAMP Currents

아직 제출이 없습니다시간 제한2초메모리 제한256 MB

문제

Thomas Edison stumbled upon an alien electrical device that appears to break known laws of physics! The device consists of nn batteries connected by mm unidirectional wires, which we will represent as vertices and edges that form a graph. The ii-th wire is directed from battery v_iv\_i to battery u_iu\_i, v_iu_iv\_i \ne u\_i. Let (v_iu_i)(v\_i → u\_i) 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:

  1. All current strength values are non-zero integers in the range \[1000,1000]\[-1000, 1000] AAMP (Alien Amperes).
  2. For every cycle found in this device, the sum of AAMP values from all wires in it must be 00. A cycle is a sequence of edges (wires) (a_1a_2)(a\_1 → a\_2), (a_2a_3)(a\_2 → a\_3), \dots,(a_k1a_k)(a\_{k-1} → a\_k), (a_ka_1)(a\_k → a\_1). If edges (xy)(x → y) and (yx)(y → x) both exist, they also form a cycle – the wires are unidirectional.

Help him with this task.

입력

The first line contains two integers nn and mm – the number of batteries and the number of wires in the device, respectively. Next, mm lines contain two integers each v_iv\_i and u_iu\_i, which mean that the ii-th wire goes from battery v_iv\_i to u_iu\_i.

출력

Print mm lines containing one number each: the ii-th number should be the current strength of ii-th wire (in AAMP). Each number should be non-zero and in the range of \[1000,1000]\[-1000, 1000]. If multiple answers exist, you may print any one of them.

제한

  • 1n1051 ≤ n ≤ 10^5
  • 1m21051 ≤ m ≤ 2 \cdot 10^5
  • 1v_i,u_in1 ≤ v\_i , u\_i ≤ n, v_iu_iv\_i \ne u\_i

힌트

Note that there can be multiple wires from battery xx to yy. Also note that wire (xy)(x → y) with strength 33 AAMP is not the same as (yx)(y → x) with strength 3-3. As mentioned before, wires are unidirectional and can have a negative current strength - that’s one of the mysteries of this device ...