405050: GYM101755 C Third-Party Software
Description
Pavel is developing a game. To do that, he needs functions available in a third-party library too famous to be called. It is known that the function i first appeared in version ai and existed until version bi, and starting from the version bi + 1, it is absent in this library.
The library is not free and Pavel needs all the functions. Which minimal number of versions he need to purchase to be able to use all the functions?
InputThe first line contains a single integer n (1 ≤ n ≤ 200000) — the number of the functions.
Each of the next n lines contains two integers ai and bi (1 ≤ ai ≤ bi ≤ 109) — the interval of library versions where function i was available.
OutputIn the first line output a single integer k — the minimal number of library versions need to be purchased to unlock all functions.
In the second line output k distinct integers — the numbers of versions need to be purchased.
If there are several possible answers, output any of them.
ExampleInput5Output
2 4
1 3
2 3
3 6
4 5
2
3 4