Processing math: 100%
The k-th candy - MarisaOJ: Marisa Online Judge

The k-th candy

Time limit: 1000 ms
Memory limit: 256 MB

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

  • The first line contains 3 integers n,q.
  • Next n lines, each line contains 2 integers ai,wi.
  • Next q lines, each line contains a single integer k, a query.

Output

  • Print q lines, ith is the answer for query i.

Constraints

  • 1≤n,q≤105.
  • 1≤ai,wi≤109.
  • 1≤k≤a1+a2+…+an≤1014.

Example

Input:

3 3
2 2
1 1
3 3
1
3
5

Output:

1
2
3