# TopCoder

Caido
$\mathbb{W}\mathcal{aimai}\sim$

78.3% (18/23)

45.3% (82/181)

# Description

$p_0,p_1,\cdots,p_{M-1}$ 是 $M$ 個 $1 \sim N$ 的排列，且對於 $i = 1, 2, 3, \cdots, M-1$ ，$p_i$ 是 $p_{i-1}$ 交換第 $x_i$ 和第 $y_i$ 個數字得到的排列。假設依照字典序排序這 $M$ 個排列後我們有 $p_{a_1} \le p_{a_2} \le \cdots \le p_{a_M}$（若有一樣的排列，則讓下標較小的排列出現在前面），請輸出 $a_1, a_2,\cdots,a_M$。

3 4
3 1 2
1 2
1 3
2 3

1 3 2 0

2 3
1 2
1 2
1 2

0 2 1

# Problem Source

No. Testdata Range Constraints Score
1 0~34 $N, M \leq 10^ 5$ 100

# Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 256000 65536 1
1 1000 256000 65536 1
2 1000 256000 65536 1
3 1000 256000 65536 1
4 1000 256000 65536 1
5 1000 256000 65536 1
6 1000 256000 65536 1
7 1000 256000 65536 1
8 1000 256000 65536 1
9 1000 256000 65536 1
10 1000 256000 65536 1
11 1000 256000 65536 1
12 1000 256000 65536 1
13 1000 256000 65536 1
14 1000 256000 65536 1
15 1000 256000 65536 1
16 1000 256000 65536 1
17 1000 256000 65536 1
18 1000 256000 65536 1
19 1000 256000 65536 1
20 3000 256000 65536 1
21 3000 256000 65536 1
22 3000 256000 65536 1
23 3000 256000 65536 1
24 3000 256000 65536 1
25 3000 256000 65536 1
26 3000 256000 65536 1
27 3000 256000 65536 1
28 3000 256000 65536 1
29 3000 256000 65536 1
30 3000 256000 65536 1
31 3000 256000 65536 1
32 3000 256000 65536 1
33 3000 256000 65536 1
34 3000 256000 65536 1