Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

E. Buses and People

time limit per test

1 secondmemory limit per test

256 megabytesinput

standard inputoutput

standard outputThe main Bertown street is represented by a straight line. There are 10^{9} bus stops located on the line. The stops are numbered with integers from 1 to 10^{9} in the order in which they follow on the road. The city has *n* buses. Every day the *i*-th bus drives from stop number *s*_{i} to stop number *f*_{i} (*s*_{i} < *f*_{i}), it stops on all intermediate stops and returns only at night. The bus starts driving at time *t*_{i} and drives so fast that it finishes driving also at time *t*_{i}. The time *t*_{i} is different for all buses. The buses have infinite capacity.

Bertown has *m* citizens. Today the *i*-th person should get from stop number *l*_{i} to stop number *r*_{i} (*l*_{i} < *r*_{i}); the *i*-th citizen comes to his initial stop (*l*_{i}) at time *b*_{i}. Each person, on the one hand, wants to get to the destination point as quickly as possible, and on the other hand, definitely does not want to change the buses as he rides. More formally: the *i*-th person chooses bus *j*, with minimum time *t*_{j}, such that *s*_{j} ≤ *l*_{i}, *r*_{i} ≤ *f*_{j} and *b*_{i} ≤ *t*_{j}.

Your task is to determine for each citizen whether he can ride to the destination point today and if he can, find the number of the bus on which the citizen will ride.

Input

The first line contains two integers *n* and *m* (1 ≤ *n*, *m* ≤ 10^{5}) — the number of buses and the number of people.

Then *n* lines follow, each of them contains three integers: *s*_{i}, *f*_{i}, *t*_{i} (1 ≤ *s*_{i}, *f*_{i}, *t*_{i} ≤ 10^{9}, *s*_{i} < *f*_{i}) — the description of the buses. It is guaranteed that all *t*_{i}-s are different.

Then *m* lines follow, each of them contains three integers: *l*_{i}, *r*_{i}, *b*_{i} (1 ≤ *l*_{i}, *r*_{i}, *b*_{i} ≤ 10^{9}, *l*_{i} < *r*_{i}) — the Bertown citizens' description. Some *b*_{i}-s could coincide.

Output

In the first line print *m* space-separated integers: the *i*-th number should be equal either to -1, if the person number *i* can't get to the destination point, or to the number of the bus that will ride the person number *i*. The buses are numbered with integers from 1 to *n* in the input order.

Examples

Input

4 3

1 10 10

5 6 2

6 7 3

5 7 4

5 7 1

1 2 1

1 10 11

Output

4 1 -1

Input

1 1

1 1000000000 1000000000

1 1000000000 1000000000

Output

1

Codeforces (c) Copyright 2010-2017 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jun/24/2017 20:16:53 (c2).

Desktop version, switch to mobile version.

User lists

Name |
---|