传统题 1000ms 256MiB

Krahc Paints KPH

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Description

Krahc is painting KPH.

KPH is abstract. He can be represented as a graph with nn vertices and mm edges.

Krahc's draft is abstract. It only contains the line art, so Krahc asks you to add colors.

Krahc's colors are abstract, so each color can be abstracted as a positive integer.

Krahc is abstract, so he hates monochromatic cycles. He hopes you can ensure that there are no monochromatic cycles in the painting while helping him color it.

Krahc doesn't like abstract, so he hopes you can provide the least abstract coloring scheme.

The definition of abstractness is abstract. A scheme is less abstract than another if for the first edge that differs in color, its color is smaller.

Format

Input

The first line contains two integers n,m(1n,m106)n,m\,(1\leq n,m\leq 10^6), representing the number of vertices and edges of KPH.

The next mm lines, each containing two integers ui,vi(1ui,vin)u_i,v_i\,(1\leq u_i,v_i\leq n), represent an edge between vertices uiu_i and viv_i.

Output

mm lines, each containing one integer, representing the color of the corresponding edge in the input. The colors should be positive integers, and there should be no monochromatic cycles in the graph.

It is guaranteed that a solution exists.

Samples

2 2
1 2
1 2
1
2

Hello ACM 2025

未参加
状态
已结束
规则
ACM/ICPC
题目
11
开始于
2025-8-14 13:00
结束于
2025-8-14 18:00
持续时间
5 小时
主持人
参赛人数
46