There are n candy types. There are ai candies of type i and they weigh wi each. No 2 types of candy have the same weight.
All the candies are poured onto a table and arranged in a row so that their weight form a non-decreasing list. You are given q queries, how heavy is the kth candy on the table?
Input:
3 3
2 2
1 1
3 3
1
3
5
Output:
1
2
3