Олимпиадный тренинг

Задача 43772. Triangle of Maxim


Since childhood, Maxim was a good musician and jack of all trades. Recently, he independently made a simple percussion musical instrument — triangle. He needs to know what the frequency of the sound his instrument is making.

Maxim has a professional music tuner with which you can play a note at a given frequency. Maxim acts as follows: he turns on notes with different frequencies on the tuner and for each note determines by ear whether it is closer or further to the sound emitted by the triangle than the previous note. Since Maxim's hearing is absolute, he always determines this absolutely correctly.

Maxim showed you a recording in which the sequence of frequencies set by him on the tuner is given, and about each note, starting from the second, — closer or further it is to the sound of the triangle than the previous note. It is known in advance that the sound frequency of the Maxim triangle is not less than 30 hertz and not more than 4000 hertz.

It is required to write a program that determines in what interval the frequency of the sound of a triangle can be.

Input
The first line of the input file contains the integer n — the number of notes played by Maxim using the tuner (2 ≤ n ≤ 1000). The next n lines contain Maxim's entries, and each line contains two components: a real number fi — the frequency set on the tuner, in hertz (30 ≤ fi ≤ 4000), and the word "closer" or the word "further" for every frequency except the first one.

The word "closer" means that the frequency of this note is closer to the frequency of the triangle than the frequency of the previous note, which is formally described by the relationship: |fi−ftriangle.| < |fi−1−ftriangle|

The word "further" means that the frequency of this note is further than the previous one.

If it turned out that the next note is as close to the sound of a triangle as the previous note, then Maxim could write down any of the two words mentioned above.

It is guaranteed that the results obtained by Maxim are consistent.

Imprint
In the output file, you need to output two space-separated real numbers — the smallest and the largest possible value of the sounding frequency of the triangle made by Maxim. Numbers must be printed with a precision of at least 10−6.

 
Examples
# Input Output
1 3
440
220 closer
300 further
30.0 260.0
2 4
554
880 further
440 closer
622 closer
531.0 660.0