---
{"languages_supported":{"0":"NA"},"title":"M2","category":"NA","old_version":true,"problem_code":"M2","tags":{"0":"NA"},"layout":"problem"}
---
<h3> All submissions for this problem are available. </h3><p>It's time for the annual exciting Motorbike Race in Byteland.</p>
<p>There are N motorcyclists taking part in the competition. Johnny is watching the race. At the present moment (time 0), Johnny has taken note of the current velocity and position of each motorcyclist.</p>
<p>Johnny wants to know at a given point of time, which motorcyclist is in a specific place in the rank list. Please help him!</p>
<p>If at any given time two motorcyclists are in same position, the motorcyclist with the smaller index will be placed before the one with the larger index.</p>
<p>To make the problem simple, Johnny assumes that each motorcyclist is moving at a constant velocity.</p>
<h3>Input</h3>
<p>The first line contains a number t (about 10) which is the number of test cases. Then t test cases follow. Each test case has the following form.</p>
<p>The first line of the test case contains a number N (1 <= N <= 20000), the number of motorcyclists.</p>
<p>The i-th line in the next N lines contains two numbers, v and x, which are the velocity and the current position of the i-th motorcyclist (1 <= v, x <= 100,000).</p>
<p>The next line contains a number Q (1 <= Q <= 20000), the number of time queries.</p>
<p>Each line in the next Q lines contains two numbers, t (1 <= t <= 1,000,000,000) and k (1 <= k <= n), representing the query: "at time t, which motorcyclist is positioned k-th in the rank list?"</p>
<h3>Output</h3>
<p>For each test case, print Q lines, with each line containing the index of the motorcyclist for the corresponding query.</p>
<p>Remember to print a new line after each test case.</p>
<h3>Example</h3>
<pre>
<b>Input:</b>
1
4
2 100
3 50
4 60
5 1
4
1 1
50 2
60 4
100 1
<b>Output:</b>
1
4
1
4
</pre>