Triangulation#5958

Triangulation

2 seconds
256 megabytes
Easy

A polygon with vertices is provided. This polygon has no self-intersections or self-tangencies. Your task is to triangulate the polygon, meaning you need to divide it into exactly N-2 triangles, ensuring the following conditions are satisfied:

Input

The first line contains the integer (3 \leq N \leq 5000), representing the number of vertices of the polygon. The next lines each contain two integers: x_i,\ y_i (-10000 \leq x_i,\ y_i \leq 10000), which are the coordinates of the polygon's vertices listed in counterclockwise order. It is guaranteed that all points are distinct. Furthermore, any pair of sides shares exactly one common point if they are adjacent, and none otherwise.

Output

Output N-2 lines, each containing three distinct integers: a_i,\ b_i, and c_i (1 \leq a_i,\ b_i,\ c_i \leq N). These integers are the indices of the vertices of the original polygon that form the -th triangle. The vertices of the polygon are numbered starting from in the order they appear in the input.

If multiple triangulation solutions exist, any valid one can be provided. Triangles can be listed in any order, and the indices of the vertices within each triangle can also be in any order.

Examples

Example 1

Loading
Loading