Given n(<=10^5) stright lines,numbered from 1 to n, each of the form y = a*x + b where a and b is provided in the input.Now you are given 10^5 queries where we have to find the line whose y is maximum at a given x in the query,if there are more than one such line ,output the smallest indexed line.How to approach this type of problem?? Any Help would be greatly appreciated.

Thanks.