Hit

주어진 모든 구간이 점을 하나 이상 포함하도록 n개 이하의 정수 점을 배치하되, 한 구간에 들어가는 점의 최대 개수가 최소가 되게 하는 문제입니다.

어려움8그리디정렬구간이분 탐색아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

Place at most n integer points on the number line in such a way that each of the given n segments [li, ri] contains at least one point, and the largest number of points contained inside one of the given segments is as small as possible.

입력

The first line contains a single integer t (1 ≤ t ≤ 105), denoting the number of test cases.

Each test case is described with an integer n (1 ≤ n ≤ 105), followed by n lines containing two integers li and ri each (−109 ≤ li < ri ≤ 109), denoting a segment containing points li, li + 1, . . . , ri. Segments may coincide.

The sum of n over all test cases does not exceed 105.

출력

For each test case, display the largest number of points inside one of the given segments in your placement, followed by the number of points you place k (1 ≤ k ≤ n), followed by k distinct integers xi (−109 ≤ xi ≤ 109), denoting the coordinates of the points you place.