Putnam Rank Range

No attempts yetTime limit2sMemory limit512 MB

Problem

After strong results in programming contests, you take part in the Putnam mathematical competition. In this contest a higher score means a better (smaller) rank. Contestants who attain the same score are all tied and together occupy a block of consecutive ranks.

The average rank of a score is the arithmetic mean of the ranks occupied by the contestants who attained it. For example, if three people are tied across ranks 1, 2 and 3, the average rank of that score is $2$.

Given the average rank of every distinct score, determine the exact range of ranks (from the best rank to the worst rank) that your score occupies. For instance, if $25$ contestants scored higher than you and, counting yourself, $4$ contestants share your score, then your range is $26$–$29$.

Input

The first line contains an integer $N$ ($1 \le N \le 100000$).

Each of the next $N$ lines contains two numbers separated by a space. The first is a score $S$ attained by one or more contestants; it is an integer with $0 \le S \le 3 \cdot 10^9$. The second is the average rank $R$ for that score, with $0 \le R \le 3 \cdot 10^8$; it is a decimal that is always a multiple of $0.5$ (for example 20.5).

The last line contains your score, which is guaranteed to equal the first number on one of the previous $N$ lines.

The $N$ score lines are not necessarily given in sorted order.

Output

Print two lines: the best (smallest) rank and the worst (largest) rank of the block of contestants who share your score, in that order.