# Edge Coloring of Bipartite Graph

AC一覧

## Problem Statement問題文

Given a bipartite graph with $L + R$ vertices and $M$ edges. $i$-th edge is $(a_i, b_i)$.

Calculate the proper edge coloring which gives the edge chromatic number.

## Constraints制約

• $1 \leq L, R \leq 100{,}000$
• $1 \leq M \leq 100{,}000$
• $0 \leq a_i < L$
• $0 \leq b_i < R$

## Input入力

$L$ $R$ $M$
$a_0$ $b_0$
$a_1$ $b_1$
$\vdots$
$a_{M - 1}$ $b_{M - 1}$


## Output出力

$K$
$c_0$
$c_1$
$\vdots$
$c_{M - 1}$


$K$ is the edge chromatic number, and $c_i$ is the integer which repersents the color of the i-th edge. $c_i$ should satisfy $0 \leq c_i < K$.

$K$ は辺彩色数、$c_i$ は $i$ 番目の辺の色を表す整数。 $c_i$ は $0 \leq c_i < K$ を満たすとする。

## Sampleサンプル

### # 1

4 4 7
1 1
2 2
0 0
3 1
1 2
2 0
3 2

3
0
2
1
2
1
0
0


Timelimit: 10 secs

Before submitting, please confirm terms and conditions