Q has $m$ distinct pairs $\{(a_i, b_i)\}_{i=1}^m$, where for all $1 \le i \le m$, $1 \le a_i < b_i \le n$. These $m$ pairs satisfy the following property: there do not exist $1 \le i, j \le m$ such that $a_i < a_j < b_i < b_j$.
D has a permutation $p$ of $1 \sim n$. Q and D use their pairs and the permutation to construct an undirected graph $G = (V, E)$ with $n$ vertices and $m$ edges, where $V = \{1, 2, \dots, n\}$ and $E = \{(p_{a_i}, p_{b_i}) \mid i \in \{1, 2, \dots, m\}\}$.
Now I knows the graph $G$. He wants to know what the permutation $p$ in D's hand could be, given the property of Q's $m$ pairs. Since I has insufficient information, there may be many possible permutations $p$. I hopes you can tell him the one that is lexicographically smallest.
Q, D, and I are good friends, and they guarantee they will not deceive each other; therefore, there exists at least one permutation $p$ that satisfies the conditions.
Input
The first line contains two integers $c, T$, representing the test case ID and the number of test cases. The following lines contain each test case. For the example, $c = 0$.
For each test case, the first line contains two integers $n, m$, representing the number of vertices and edges of $G$. The next $m$ lines each contain two integers $u_i, v_i$ ($1 \le i \le m$), describing an edge in $G$.
Output
For each test case, output a single line containing a permutation $p$ of $1 \sim n$, representing the lexicographically smallest permutation that satisfies the given conditions. It is guaranteed that at least one such permutation $p$ exists.
Examples
Input 1
0 2 4 2 1 3 4 2 4 5 2 3 4 2 3 1 1 4 3 4
Output 1
1 2 4 3 1 3 2 4
Note
This example contains 2 test cases.
- For the first test case:
- If D's permutation is $[1, 2, 3, 4]$, then Q's pairs are $\{(1, 3), (2, 4)\}$. However, taking $i=1, j=2$, we have $1 < 2 < 3 < 4$, which does not satisfy Q's property.
- If D's permutation is $[1, 2, 4, 3]$, then Q's pairs are $\{(1, 4), (2, 3)\}$, which can be proven to satisfy the property.
- For the second test case, if D's permutation is $[1, 3, 2, 4]$, then Q's pairs are $\{(2, 3), (3, 4), (1, 2), (1, 4), (2, 4)\}$, which can be proven to satisfy the property.
Constraints
For all test cases: $1 \le T \le 10$ $2 \le n \le 10^5$, $0 \le m \le 2n$ $\forall 1 \le i \le m, 1 \le u_i, v_i \le n, u_i \neq v_i$, i.e., $G$ has no self-loops. $\forall 1 \le i < j \le m, \{u_i, v_i\} \neq \{u_j, v_j\}$, i.e., $G$ has no multiple edges. * It is guaranteed that at least one permutation $p$ satisfies the conditions.
| Test Case ID | $n \le$ | Special Property |
|---|---|---|
| 1, 2 | 10 | None |
| 3, 4 | 2,000 | AC |
| 5, 6 | 2,000 | A |
| 7, 8 | 2,000 | C |
| 9 ~ 11 | $10^5$ | None |
| 12 | $10^5$ | ABC |
| 13 ~ 15 | $10^5$ | AC |
| 16 ~ 18 | $10^5$ | A |
| 19 ~ 21 | $10^5$ | C |
| 22 ~ 25 | $10^5$ | None |
- Special Property A: $G$ is connected.
- Special Property B: The degree of every vertex in $G$ is at most 2.
- Special Property C: $G$ contains no simple cycles, i.e., $G$ is a forest.