#P91E. Igloo Skyscraper
Igloo Skyscraper
Description
Today the North Pole hosts an Olympiad in a sport called... toy igloo skyscrapers' building!
There are n walruses taking part in the contest. Each walrus is given a unique number from 1 to n. After start each walrus begins to build his own igloo skyscraper. Initially, at the moment of time equal to 0, the height of the skyscraper i-th walrus is equal to ai. Each minute the i-th walrus finishes building bi floors.
The journalists that are reporting from the spot where the Olympiad is taking place, make q queries to the organizers. Each query is characterized by a group of three numbers li, ri, ti. The organizers respond to each query with a number x, such that:
1. Number x lies on the interval from li to ri inclusive (li ≤ x ≤ ri).
2. The skyscraper of the walrus number x possesses the maximum height among the skyscrapers of all walruses from the interval [li, ri] at the moment of time ti.
For each journalists' query print the number of the walrus x that meets the above-given criteria. If there are several possible answers, print any of them.
The first line contains numbers n and q (1 ≤ n, q ≤ 105). Next n lines contain pairs of numbers ai, bi (1 ≤ ai, bi ≤ 109). Then follow q queries i the following format li, ri, ti, one per each line (1 ≤ li ≤ ri ≤ n, 0 ≤ ti ≤ 106). All input numbers are integers.
For each journalists' query print the number of the walrus x that meets the criteria, given in the statement. Print one number per line.
Input
The first line contains numbers n and q (1 ≤ n, q ≤ 105). Next n lines contain pairs of numbers ai, bi (1 ≤ ai, bi ≤ 109). Then follow q queries i the following format li, ri, ti, one per each line (1 ≤ li ≤ ri ≤ n, 0 ≤ ti ≤ 106). All input numbers are integers.
Output
For each journalists' query print the number of the walrus x that meets the criteria, given in the statement. Print one number per line.
5 4<br>4 1<br>3 5<br>6 2<br>3 5<br>6 5<br>1 5 2<br>1 3 5<br>1 1 0<br>1 5 0<br>
5 4<br>6 1<br>5 1<br>2 5<br>4 3<br>6 1<br>2 4 1<br>3 4 5<br>1 4 5<br>1 2 0<br>
5<br>2<br>1<br>5<br>
3<br>3<br>3<br>1<br>