Stevie : " The second half of a programming contest is just as important as the second half of a football match, it's the decisive part ". So, here you are presumably having got over the first half. Also, let's not forget this guy who has given us some real memories to cherish :
You are given N segments , where . Now, you need to answer some queries based on these segments.
Overall, you need to answer Q queries. In each query you shall be given 2 integers K and X. You need to find the size of the smallest segment that contains point X.
If no K segments contain point X , print 1 instead as the answer to that query.
A segment is said to contain a point X, if . When we speak about the smallest segment, we refer to the one having the smallest size. We define the size of a segment to be the number of integral points it contains, i.e.
Input Format :
The first line contains a single integer N,
Each of the next N lines contains 2 space separated integers, where the 2 integers on the line denote the start and end points of the segment given to you.
The next line contains a single integer Q.
Each of the next Q lines contains 2 space separated integers K and X.
Output Format :
Print the ansnwer to each query on a new line.
Constraints :
,where
For the second query, the smallest segment containing the point 2 is segment .
Similarly, for the first query, the smallest segment containing point 4 is the segment