#Lutece3368. Du Cuo Ti Le
Du Cuo Ti Le
Description
You are given a sequence . Initially, all numbers are zero.
There are operations. The -th operation is represented by two integers , which assigns to . It is guaranteed that all the integers, , are distinct.
You need to perform each operation exactly once, in arbitrary order.
You want to minimize and maximize the value of index such that after all operations. Output the minimum and maximum values of index .
Note that the minimal and maximal values can appear in different performance orders.
Input
The first line contains an integer .
The -th line of the next lines contains a pair of integers . It is guaranteed that all the integers, , are distinct.
Output
Output two integers in one line denoting the minimal and the maximal value of index .
Samples
2
1 3
2 4
1 3
Resources
The 21st UESTC Programming Contest Preliminary