"Joining Points" is a single-player game. Choose two integers greater than 2 and call them $g$ and $r$. Draw four points at the vertices of a square: the top two are green and the bottom two are red. Place more green and red points inside the square so that no three points, including the four corners, lie on one line. Stop when there are $g$ green points and $r$ red points in total.
After the board is ready, join points with line segments. You may connect two points when:
Points $u$ and $v$ are in the same component when you can travel from $u$ to $v$ using segments already drawn.
You win by connecting all green points into one component with exactly $g-1$ green segments, and all red points into another component with exactly $r-1$ red segments. When the points are placed as described, a winning construction always exists.
You receive a square board of side length $s$ with $g$ green points and $r$ red points at integer coordinates $(x_i, y_i)$. Green points are numbered 1 through $g$: point 1 is at $(0,s)$, point 2 at $(s,s)$, and interior points are numbered 3 through $g$. Red points are numbered 1 through $r$: point 1 is at $(0,0)$, point 2 at $(s,0)$, and interior points are numbered 3 through $r$.

The figure shows one valid finish: all green points in one component and all red points in another. No three points are collinear, and segments meet only at endpoints.
Given the coordinates of all green and red points, output how to draw $g-1$ green segments and $r-1$ red segments that connect each color into a single component without crossing segments.
Print $(g-1)+(r-1)$ lines, one per drawn segment.
Each line contains two space-separated integers and one character. The integers are the numbers of the joined points; the character is g for green or r for red.
The order of lines and the order of endpoints within a line do not matter.