Limits 2s, 512 MB · Custom Checker

Oyler received a peculiar homework from his school. The teacher gave him a positive number $n$ and told him to construct an array of length $n$, whose entries are in the range $1, \cdots , n$. The teacher also gave some extra conditions in the form of "$l$ $r$", meaning that the numbers at indices between $l$ and $r$ (inclusive) should be distinct.

So Oyler is trying to make such an array. To fill up the array, he needs to buy numbers from the local shop. If he buys a number $x$, he can use that number at as many indices as he likes. In order to keep the cost of this homework manageable, he wants to buy as few numbers as possible. Given the conditions, output an array that uses minimum number of distinct numbers and satisfies the conditions.

Input

There will be $T$ testcases.

Each testcase will begin with a line containing space separated numbers $n$ and $c$. $n$ is the length of the array to be created, $c$ is the number of conditions.

The next $c$ lines will contain the requirements. Each requirement is given as space separated numbers $l$ and $r$, meaning that the numbers which have index between $l$ and $r$ (inclusive) are distinct.

$1 \leq T \leq 10^5$
$1 \leq n \leq 10^5$
$0 \leq c \leq 10^5$
$ 1 \leq l \leq r \leq n $
The sum of $n$ over all testcases $\leq 10^5$
The sum of $c$ over all testcases $\leq 10^5$

Output

For each testcase, output the final array in one line. The numbers should be space separated and in the range $[1, n]$.

If there are multiple answers, you can output any such array.

Sample

InputOutput
1
5 2
1 3
2 4
1 3 2 1 1

Submit

Login to submit.

Statistics

67% Solution Ratio
ASIF_GSCEarliest, Mar '21
Kuddus.6068Fastest, 0.0s
ASIF_GSCLightest, 655 kB
blizzardShortest, 213B
Toph uses cookies. By continuing you agree to our Cookie Policy.