Distinct Values
시간 제한2초메모리 제한256 MB
구간마다 서로 다른 값만 들어 있어야 한다는 조건이 여러 개 주어질 때, 이를 만족하는 양의 정수 배열 중 사전순으로 가장 작은 배열을 만든다.
문제
Chiaki has an array of positive integers. You are told some facts about the array: for every two elements and in the subarray (), holds.
Chiaki would like to find a lexicographically minimal array which meets the facts.
입력
There are multiple test cases. The first line of input contains an integer , indicating the number of test cases. For each test case:
The first line contains two integers and () -- the length of the array and the number of facts. Each of the next lines contains two integers and ().
It is guaranteed that neither the sum of all nor the sum of all exceeds .
출력
For each test case, output integers denoting the lexicographically minimal array. Integers should be separated by a single space, and no extra spaces are allowed at the end of lines.