Company ABC is holding an antique auction. In the auction, there are N, 1≤N≤1000, lots. We number the lots from 1 to N. There are M, 1≤M≤500, bidders participated in the auction. We number the bidders from 1 to M. The winning bid for each lot is determined by the following rules:
• Each lot has a reserved price, which is a positive integer.
• Each bidder may submit at most one bid to each lot whose amount must be a positive integer.
• A valid bid for a lot is one that is at least the reserved price for the lot. All invalid bids are not considered.
• The largest valid bid wins the lot and is called the winning bid. In case of tie bids, the bidder with the smaller bidder number wins. If there is no valid bid for a lot, then this lot is not sold.
• The second largest bid is a valid bid that does not win if one exists; otherwise, it is the reserved price.
• If a bidder wins a lot, then the final hammer price for this lot is either 10% over the second largest bid or the largest valid bid, depending on which one is smaller. If the final hammer price is not an integer, then it is truncated to the nearest integer.
• Given the reserved price and the bids for each lot, your task is to decide the total final hammer prices for a given k, 0<k≤M, bidders.
Input Format
The input contains N+3+k lines.
Line 1: N
Line 2: M
Line 3: r1,b1,1,p1,1,b1,2,p1,2,−1
…
Line i+2: ri,bi,1,pi,1,bi,2,pi,2,−1
…
Line N+2: rN,bN,1,pN,1,bN,2,pN,2,−1
Line N+3: k
Line N+4: q1
…
Line N+3+i: qi
…
Line N+3+k: qk
In Line i+2, ri is the reserved price for lot i. The number bi,j and pi,j are the jth bid for lot i from bidder bi,jwith the amount pi,j . Note that a space is between each number. The number −1 is added to mark the end of bids for a lot. In Line N+3, k is given. In line N+3+i, you are asked to provide the total hammer prices for bidder qi.
Output Format:
The output contains k lines.
Line 1: h1
…
Line i: hi
…
Line k: hk
The total hammer prices for bidder qi is hi.
Hint
In the sample, the bidder 1 got the the first lot 1 at hammer price 13.
样例输入
3
3
11 2 12 1 15 -1
5 3 4 -1
23 1 32 2 35 3 40 -1
1
1
样例输出
13