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

Ural Championship 2005 Round I

About     Problems     Submit solution     Judge status     Standings
Contest is over

B. Death Star

Time limit: 1.0 second
Memory limit: 64 MB
A long time ago in a galaxy far, far away…
Well, let's skip these well known entry words of the famous movie. No doubt, anyone knows them.
Anyway, a long time ago in a galaxy far, far away there was a space station named "Death star". For those of you who do not remember it, we would remind that it mostly looked like a big metal ball with lots of turrets on its surface. And somewere between turrets there were towers with maneuring engines on a top of each tower; that allowed the station to turn in space. All the engines were the same: standard krypton engines with autonomous power supply. And all the towers were the same. Each of the engines could be in two distinct states: switched off and switched on to a maximum power. But it was not a problem since each engine could be rotated individually relative to the station.
Unfortunately, the engine control cable was damaged after one of the space battles: it was melted by the direct hit of a rebel laser weapon. So all the manoeuvre drives became uncontrollable. All of them which were at maximal power just kept working. Switched off engines remained in that state. Death Star won the battle, but stuck manoeuvre drives made a strange effect: instead of smooth and majestic movement through space, station makes unpredictable rotations which are unsuitable for the Imperial fleet flagship.
It makes Emperor annoyed. No, not just annoyed but furious, because it seems to him that the station rotates faster and faster, and he already feels nauseous.
You have to fix the situation as soon as possible, otherwise you are not guaranteed to stay alive for long.
Engine control cable can be fixed in a week. You see, it is too long. So you have to establish another engine tower with a maintenance engine to stop the rotation. And you have to do this really quickly.
You may have thought that you would need to solve a lot of complex differential equations and to write engine controlling program. No, not at all. As a station engineer, you must know that jet thrust of a maintenance engine does not change over time. It depends on jet nozzle size only. So you only have to find the suitable place for the engine tower, calculate jet nozzle size, set up thrust vector and switch the maintenance engine on. No matter how you do it. Just make it in such a way that the working krypton engines won't further speed up the rotation.

Input

In the first line of input, some technical data on the Death Star station are given. You know, these are top secret data, but without them you will definitely fail your mission.
The first number gives a radius of station in meters (it ranges from 100 to 2000), then total station mass is given (in kilograms, not greater than 40000000, you may assume that the mass is uniformly distributed throughout the station), followed by the height of a standard engine tower (in meters above the station surface; maintenance engine will be placed on the very same tower, and you may place this maintenance engine tower anywhere on the station surface).
Next line of input contains krypton engine description. It starts with a number F — standard jet thrust of krypton engine in newtons (ranges from 1 to 100000). Then an integer number N (1 ≤ N ≤ 9) follows. It is a number of krypton engines currently working at maximum power.
Each of the following N lines contains description of working krypton engine placements. Each line contains 4 numbers. These are: longitude (from 0 to 360 degrees) and latitude (from −90 to 90 degrees) of engine placement relative to the station. Other two numbers define the jet thrust vector of the engine: if this vector is applied to the center of the station, then it would intersect station surface at the point with longitude and latitude given by these two numbers.

Output

Print 5 numbers with a precision of eight decimal digits: two numbers (longitude and latitude) must define place to establish the maintenance engine tower, then two numbers must define jet thrust vector (in notation described above) of the maintenance engine, and the last number must define jet thrust in newtons. You should choose the placement with the least jet thrust among different possible maintenance engine placements.

Sample

inputoutput
100.3 1000000.45 15.5
156.5 1
0.0 0.0 90.0 0.0
0.00 0.00 270.00 0.00 156.50
Problem Author: Pavel Egorov (idea by Aleksandr Mironenko)
Problem Source: IX Urals Programming Contest. Yekaterinburg, April 19-24, 2005
To submit the solution for this problem go to the Problem set: 1372. Death Star