PivotOJ

Antimatter Rain

시간 제한: 7000ms메모리 제한: 1024MB출처: ICPC Rocky Mountain Regional 2020BOJ 21204

문제

You've heard of acid rain but have you heard of antimatter rain? Antimatter rain is so potent that when it comes into contact with another object, it immediately disintegrates both itself and the object. Kayla's job as a SpaceFleet Researcher is gathering weather data on exotic planets. This time, their assignment is to monitor the antimatter rainfall.

Sensors are set up in the planet's atmosphere and are about to be rained on with antimatter rain. Oh no! Kayla monitors a single 2D section. Each sensor is either a single horizontal strip or a single point. When one or more antimatter droplet fall on a single sensor, all of those droplets and the sensor disintegrate simultaneously. That is, they disappear. All other droplets will drop past where the sensor used to be.

Kayla sees all the antimatter rain drops the moment before they all start to fall. All droplets fall at exactly the same rate.

For each droplet, Kayla wants to know if and where it will disintegrate. Help them out with this demanding task!

Illustration of the first sample. The vertical lines connect the drops to the sensor they hit. The drop with no associated vertical line will not hit any sensor.

입력

The first line of input contains two integers DD (1D1000001 \leq D \leq 100\,000), which is the number of antimatter droplets, and SS (1S1000001 \leq S \leq 100\,000), which is the number of sensors.

The next DD lines describe the droplets, in order. Each of these lines contains two integers xx (1x1091 \leq x \leq 10^9), which is the xx-coordinate of the droplet and yy (1y1091 \leq y \leq 10^9), which is the yy-coordinate of the droplet.

The next SS lines describe the sensors. Each line contains three integers x1x_1, x2x_2 (1x1x21091 \leq x_1 \leq x_2 \leq 10^9), which is the leftmost and the rightmost xx-coordinate of the sensor, and yy (1y1091 \leq y \leq 10^9), which is the yy-coordinate of the sensor.

It is guaranteed that no two drops will start in the same location, no drop will start on any sensor, and no two sensors touch (not even at a single point).

출력

For each droplet, in order, display a single number indicating the yy-coordinate that it will disintegrate. If the droplet does not disintegrate, display 00 instead. These values should appear on separate lines.

예제

예제 1

입력
5 3
1 8
2 3
2 8
5 8
5 9
3 6 6
1 7 4
1 3 1
출력
4
1
4
6
0

예제 2

입력
6 3
1 2
4 8
5 10
6 10
7 10
8 10
1 1 1
3 4 3
5 7 9
출력
1
3
9
9
9
0
코드를 제출하려면 로그인하세요.