Optimal Truck

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

Peter is going to buy a truck and start a small transportation business. He studied the market and found out that there are nn potential customers in his city. There are m_im\_i contract options for the ii-th client. Each option is specified by two numbers: w_ijw\_{ij} --- the minimum capacity of the truck, which is required to fulfill the contract, and c_ijc\_{ij} --- the profit that Peter will receive if he concludes this contract. No more than one contract can be concluded with each client.

Now Peter is thinking which truck is better to buy in order to get the profit he needs. He has qq options. In the ii-th option, Peter wants his profit to be at least x_ix\_i. Help him, for each of the options, find the minimum capacity of the truck with which you can make such a profit.

입력

The first line contains the integer nn (1n1051\le n\le 10^5).

This is followed by nn blocks describing contract options for each of the potential customers. Each such block begins with the number m_im\_i, followed by m_im\_i pairs of numbers w_ij,c_ijw\_{ij}, c\_{ij} (1m_i1\le m\_i, m_i5105\sum m\_i \le 5 \cdot 10^5, 1w_ij,c_ij1091\le w\_{ij}, c\_{ij}\le 10^9).

Next comes the number qq (1q1051\le q\le 10^5). This is followed by the qq numbers x_ix\_i (1x_i1091\le x\_i\le 10^9).

출력

Print qq numbers, the minimum carrying capacity of the truck, with which you can get the required profit, for each of the options. If it is impossible to get the required profit, print 1-1 for the corresponding option.