#435. Kart Race

Kart Race

Description

The annual kart race will soon be held in Byteland. The map of the race consists of nn different intersections and mm one-way streets. These intersections are labeled from 11 to nn, the ii-th of which is located at (xi,yi)(x_i,y_i). There are no cycles in the street network, one can only drive to some intersections with the strictly larger value of x-coordinate. The streets may only intersect at the intersections.

The race will start at the 11-st intersection and will finish at the nn-th intersection. The racers can pick their routes themselves, but they can only drive along the streets marked on the map. It is guaranteed that one can reach any place from 11, and any place can reach nn, so any route is valid.

The kart race attracts so many sponsors. Each intersection has a slot to set a banner, if you choose to set a banner at the ii-th intersection, the race company will get wiw_i profits. You are a middleman in the race company, your job is to choose some intersections to set banners such that the total profits are maximized. You know that no racer is willing to see more than a banner, so for every possible route from 11 to nn, you should guarantee that at most one intersection is chosen.

Format

Input

The first line contains a single integer TT (1T10001 \leq T \leq 1\,000), the number of test cases. For each test case:

The first line of the input contains two integers nn and mm (1n1000001 \leq n \leq 100\,000, 1m2n1\leq m\leq 2n), denoting the number of intersections and the number of one-way streets.

In the next nn lines, the ii-th line contains three integers xix_i, yiy_i and wiw_i (0xi,yi1090\leq x_i,y_i\leq 10^9, 1wi1091\leq w_i\leq 10^9), describing the ii-th intersection. It is guaranteed that no two intersections share the same coordinator.

Each of the next mm lines contains two integers uiu_i and viv_i (1ui,vin1 \leq u_i, v_i \leq n, xui<xvix_{u_i} < x_{v_i}), denoting a one way street from uiu_i to viv_i. It is guaranteed that each pair of uiu_i and viv_i will be described at most once.

It is guaranteed that the sum of all nn is at most 15000001\,500\,000.

Output

For each test case, print a single integer in the first line, denoting the maximum total profits. Then print a sequence of integers in the second line, denoting the indexes of intersections you choose to set a banner. If there are multiple optimal solutions, you should print the lexicographically smallest one.

Samples

2
6 6
0 1 1
2 2 1
1 0 1
1 2 1
2 0 1
3 1 1
1 4
3 5
2 6
5 6
1 3
4 2
2 1
0 0 8
1 1 9
1 2

2
2 3
9
2