Penguin Bashing

No attempts yetTime limit1sMemory limit128 MB

Problem

In a well-known online game you play a yeti whose goal is to hit a cute and cuddly penguin so that it flies as far as possible. The game is set in sunny Antarctica, where the ground is littered with obstacles left by human and robotic expeditions. The most dangerous of these are sharp, pointy metal objects called spikes, which are extremely hazardous to penguins.

Besides expeditions, Antarctica has also seen many wars, so in addition to spikes you may encounter mines on the surface. Mines are not good for a penguin's health, but their explosions do increase the distance it travels.

The best way to get a high score is to work out the optimal strategy in advance. To do that you need the following facts:

  • The yeti always strikes at an integer angle between -90 and +90 degrees: -90 is straight down, 0 is to the right, and +90 is straight up.
  • The penguin is given a total speed of 25 m/s regardless of the angle.
  • The yeti hits the 3 kg penguin at exactly one meter above the ground.
  • On touching the ground the penguin slides along it under friction, losing 5 m/s of speed for every meter traveled.
  • On hitting a mine the penguin is flung 2 m forward through the air and instantly gains 4 m/s of forward speed.
  • If the penguin hits a spike, the game ends immediately with a score of -100. Otherwise the score is the horizontal distance traveled in centimeters, rounded to the nearest integer.
  • Standard Earth gravity (9.81 m/s²) is used and drag is ignored.

Input

The first line of input contains a positive integer, the number of test cases. Then, for each test case:

  • A line with a single integer $n$ ($n < 10^5$), the number of obstacles.
  • $n$ lines, each containing:
    • A floating-point number $x_i$, the position of the obstacle in meters from the start.
    • A string describing the obstacle, either "mine" or "spike".

Output

For each test case, print one line with two integers: the highest possible score, and the angle in degrees at which the yeti must hit the penguin to achieve it. If several angles tie, print the smallest angle.