Museum
At the Federal University of Flatland, a museum dedicated to sports achievements has recently opened. The centerpiece of this museum is a hall showcasing souvenirs from various sports programming competitions.
As programming grows in popularity, the number of visitors to this hall is increasing, prompting the museum director to consider the security of these souvenirs. The director plans to enclose one or two zones containing the souvenirs, preventing visitors from freely moving between them and allowing them to view only from the outside.
The hall is designed as a convex polygon, with souvenirs positioned as points within this polygon. The director aims to select one or two triangles, using the vertices of the hall, such that these triangles do not overlap internally (i.e., their intersection area is zero), and each souvenir is contained within one of the triangles.
To minimize visitor inconvenience, the total area of the selected triangles should be as small as possible, with each triangle having a strictly positive area. Assist the director in enclosing the exhibits.
Input
The first line contains the number of test cases t. Each test case consists of the following:
The first line of each test case contains two positive integers n and m - the number of vertices of the polygon representing the hall, and the number of souvenirs in the hall (3 ≤ n ≤ 2000, 1 ≤ m ≤ 2000).
The next n lines each contain two integers xh[i]
and yh[i]
- the coordinates of the polygon's vertices in the Cartesian coordinate system (-10^9
≤ xh[i]
, yh[i]
≤ 10^9
). The vertices are listed in counterclockwise order.
The following m lines each contain two integers xs[i]
, ys[i]
- the coordinates of the souvenirs (-10^9
≤ xs[i]
, ys[i]
≤ 10^9
).
It is guaranteed that all souvenirs are strictly inside the hall, and no three of the given n + m points are collinear.
The sum of all n and the sum of all m across all test cases do not exceed 2000 each.
Output
For each of the t test cases, output the following:
If it is impossible to select one or two triangles as required, output -1 on a separate line.
Otherwise, output an integer k (1 ≤ k ≤ 2) - the number of selected triangles, followed by k lines, each containing three integers representing the indices of the vertices of the hall that form the vertices of the triangle.
If multiple optimal solutions exist, any of them can be output.
Note that the goal is to minimize only the total area of the selected triangles.
Examples
Note
The image illustrates the optimal triangle selections for the first and third test cases, as well as the souvenir arrangement in the second test case, where selecting one or two triangles is impossible.