eolymp
bolt
Try our new interface for solving problems
Problems

Platforms

Platforms

Antigravity has been widely used for a long time on the Olympia planet. The Olympian ministry of entertainment opened a new set of sightseeing platforms, that immovably hang at different heights above the Rio-ACM river. The platforms are small and may be considered as points. The river can be considered approximately straight, so all the platforms (points) are placed in a vertical plane. That is, the location of each platform can be described by two coordinates: x-coordinate specifies the horizontal distance from the river’s source, y-coordinate -- the height above the water. No platform is located exactly under any other one -- thus, all x-coordinates are distinct. Unfortunately, these platforms didn’t prove to be popular for sightseeing, so the ministry is looking for a plan how to use them in another way -- preferably such a way, which doesn’t require moving of the platforms. One of the plans suggests equipping the platforms as stations for the hang gliders (also known as delta-planes). It’s not interesting to use antigravity in sports, so hang gliders can fly from any platform to a platform of lower or equal height only. On religious grounds, Olympians never fly hang gliders in the direction opposite to the river flow. According to marketing researches, the route will be popular if and only if it allows the greatest possible number of consecutive flights from one platform to another one, next one, and so on. The length of flights has no significant influence on route’s popularity. Your task is to write a program to find which of the platforms will belong to at least one of the popular routes. \InputFile The \textbf{1}st line of the input contains the number of test cases \textbf{T}. In each test case, the first line contains the number of platforms \textbf{N} (\textbf{1} < \textbf{123456}), each of following \textbf{N} lines contains two non-negative integer numbers --- \textbf{x}- and \textbf{y}-coordinates of the corresponding platform. \OutputFile The program should write to standard output \textbf{T} two-lines groups --- the answers for the corresponding test cases. The first line in each group should contain the number of flights in the popular routes and the total number of platforms that belong to any of the popular routes. The second line in the group should contain a list (in ascending order) of \textbf{x}-coordinates of these platforms. Numbers in each line should be separated by spaces.
Time limit 2 seconds
Memory limit 64 MiB
Input example #1
1
2
2 3
4 5

Output example #1
0 0

Source All-Ukrainian Collegiate Programming Contest Semi-Final 2010