ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

1390. Shots at Walls

Time limit: 3.0 second
Memory limit: 64 MB
A new pistol is being tested. The pistol can fire shots with variant bullet speeds. In some points of time shots are fired from the point of origin with certain horizontal speeds, and in some other points of time walls are built on a horizontal platform. The walls are non-singular segments lying on lines that do not go through the point of origin. The walls may intersect. For processing of the test results, you are to determine the time that each shot bullet had been flying for. You can assume that the speed of the bullet after shot is constant.

Input

Each line of the input begins with either "shot", "wall", or "end" (without quotes). The number of lines doesn't exceed 50000. After "shot", the two coordinates of speed of the bullet are listed; the speed cannot be zero. After "wall", the four numbers follow, being the coordinates of wall's beginning and end. "end" denotes the end of the input. All the coordinates are integers whose absolute values doesn't exceed 10000. All the events are listed in chronological order, and time intervals between the events exceed the time needed to build a wall, or the time needed for bullet to reach the next wall or end of the proving ground.

Output

For each of the shots, you must output the single number, on a line by itself: the time that the bullet had been flying for, with precision of 10−6. If the bullet doesn't hit any wall, you must output "Infinite" instead of a number.

Sample

inputoutput
shot 1 0
wall 1 0 0 1
shot 1 1
shot -1 3
wall 1 0 -1 2
shot -1 3
wall 1 1 -1 1
shot -1 3
wall 2 3 2 -3
wall 3 -2 -3 -2
shot 1 -1
shot 40 -39
shot 9999 -10000
shot -1 -1
shot -3000 -2000
shot -3001 -2000
shot -3000 -2001
shot 1 0
shot 1 1
wall -1 2 10 -10
shot -1 1
shot 0 1
shot 1 1
shot 1 0
shot 1 -1
wall 0 -10000 -10000 0
shot -2 -1
end
Infinite
0.50000000000000000000
Infinite
0.50000000000000000000
0.33333333333333333333
2.00000000000000000000
0.05000000000000000000
0.00020000000000000000
2.00000000000000000000
0.00100000000000000000
Infinite
0.00099950024987506247
1.00000000000000000000
0.50000000000000000000
1.00000000000000000000
0.90909090909090909091
0.43478260869565217391
0.83333333333333333333
2.00000000000000000000
3333.33333333333333333
Problem Author: Andrew Rumyantsev
Problem Source: Petrozavodsk summer training camp, August 2005.