Under construction

Still being built. Things may change

Delaunay

Time limit2sMemory limit1024 MB

Summary
For each given triangle of levers, check whether its circumscribed circle strictly contains any other lever point.
Level

Medium7 of 10

Topics
Geometry, Math
Solved
No attempts yet

Statement

Where is the map, Billy? We need the map...

Black Dog

On this night, a gang of pirates plans to attack the Admiral Benbow and seize the treasure map. But young Jimmy Hawkins is already prepared. His pirate friend Delaunay built a clever mechanism of secret traps, and Jim waits on the second floor with nets.

The traps are a set of hidden levers on a plane. Some levers are grouped into traps. A trap is formed by any three levers, as long as its area is not zero. The areas shared by any two traps are zero. It is also guaranteed that the total area covered by the traps is maximal.

The system works as follows. As soon as a pirate steps into the area of one of the traps, Jim throws a round net from above, and the pirate is caught. The rim of the net is a circle that touches all three levers forming the trap the pirate stepped into.

The only weakness: if, at the moment the net is thrown, its inside covers a lever unrelated to the trap, the whole system fails. Jim wants to check whether the system is reliable. More precisely, he wants to know whether there is a trap such that the net for that trap (the circle circumscribed around the triangle formed by its levers) contains at least one more lever inside.

Input

The first line contains the number of tests tt (1≤t≤51 \le t \le 5). Each test starts with a line containing the number of levers nn (3≤n≤50 0003 \le n \le 50\,000) and the number of traps mm. The next nn lines contain the integer coordinates xi,yix_i, y_i (∣xi∣,∣yi∣≤10 000|x_i|, |y_i| \le 10\,000) of the levers. The next mm lines each contain three integers aj,bj,cja_j, b_j, c_j (1≤aj,bj,cj≤n1 \le a_j, b_j, c_j \le n), the numbers of the levers forming the jj-th trap.

Output

For each test, print on a separate line YES if the system is reliable, that is, no lever lies inside the circle circumscribed around any trap. Otherwise, print NO.

Examples1

  1. Example 1

    Input
    2
    4 2
    0 1
    0 -1
    -2 0
    2 0
    1 2 3
    1 2 4
    4 2
    0 1
    0 -1
    -2 0
    2 0
    3 4 2
    3 4 1
    
    Expected output
    YES
    NO