chotu-and-candy

Chotu has N candies, with each candy having 3 attributes - an ID, a sweetness value and a cost. Chotu will eat only one candy on a particular day. On any day, Chotu will eat the candy which has the highest sweetness value among all the candies present with him. If two candies have the same sweetness value, then Chotu selects the one with the lesser cost. If there is still a tie, then he selects the candy with the least ID (Note that id is unique for each candy). 

Now, Chotu asks you Q queries, each containing a single integer X between 1 and N, you need to tell the day on which Chotu will eat the candy with ID X.

Input
First line contains two integers, N and Q denoting number of candies and number of queries.
Next N lines contains 3 space separated integers X, S, C, denoting the ID of the candy, its sweetness and its cost.
Next Q lines contains a single integer X.
Output
For each of the queries, print the day on which chotu will eat the  given candy.
Constraints
1 ≤ N,Q ≤ 10^5
1 ≤ X ≤ 10^5 
1 ≤ S,C ≤ 10^8
Value of X will be distinct.

SAMPLE INPUT
4 4
1 10 90
2 12 120
3 10 100
4 10 100
1
2
3
4

SAMPLE OUTPUT
2
1
3
4

Explanation

Since the sweetness value of candy with ID 2 is highest so Chotu will eat it on day 1.
Candy 1, 3 and 4 have same sweetness but candy one has lower cost, so it will be eaten on day 2.
Candy 3 and 4 have same sweetness and cost, but candy 3 has lower ID, so it will be eaten on day 3.
Remaining candy 4 will be eaten on day 4.

Source: hackerearth | Difficulty: EASY


Solutions: