Anumber of ants are located on a two-dimensional plane, and each ant moves either upward or rightward. In each step, each ant moves one unit forward in its direction. More precisely, consider an ant located at coordinates before the step. If the ant moves upward, its coordinates after the step will be , and if it moves rightward, its coordinates after the step will be . Initially, no two ants are located at the same coordinates. If two ants collide at the same coordinate in a step, before the next step begins, their movement direction changes from up to right and from right to up. Sara is curious to know the total number of collisions. Given the initial coordinates of the ants and their directions of movement, calculate the total number of collisions for Sara.
The first line of the input contains an integer , which is the the number of ants. Then, for each , the line of the input contains two space-separated integers and , and one of the letters U
or R
. The integers denote the initial coordinates of the ant, and the letter indicates the initial direction of movement. The letter U
represents upward movement, and the letter R
represents rightward movement.
In the only line of output, print the total number of collisions if it is finite, and the word inf otherwise.