2015
09-17

# Spacecraft Monitoring

In recent years, China’s space industry has made rapid development, and recently launched the manned spacecraft shenzhou 10. Beauty Astronaut Wang Yaping even made a lesson in the spacecraft to the whole world. It means a lot to China’s space communication. And the Nanjing University of Science and Technology also contribute their strength in communication, radar and detecting guidance.
Today, there have been many aircrafts in space, they are communicating with each other in air, or with the ground monitoring points in ground (including fixed and mobile monitoring point). To simplify the problem, we assume that all the aircrafts and ground monitoring points are all in the equatorial plane. Aircrafts are all in synchronous orbit, suppose the earth’s core as point (0, 0). We already know:
Every aircraft’s or ground monitoring point’s height R relative to the earth’s core, initial angle A (rad), and some communication relationship between them.
Also every aircraft’s or ground monitoring point’s cost price P.
And the ground-to-ground price per unit distance: dd, ground-to-air price per unit distance: dk (air-to-ground the same), air-to-air price per unit distance: kk.
In order to know the general condition of the system, you should calculate the maximal average cost price of some aircrafts or ground monitoring points. The average cost price = (the sum of aircrafts’ or ground monitoring points’ cost price + communication cost price between them if it’s existing)/(the amount of the aircrafts or ground monitoring points)

Multiple cases, end with EOF;
The first line, 4 positive integers, n, dd, dk, kk, there is n aircrafts or ground monitoring points, dd, dk, kk is the same with description above. Remember that we first calculate the distance between two objects into integer, four to five homes in rounding, then calculate the communication cost price.

Next n lines, each represents an aircraft or ground monitoring point,
if the first letter is ‘d’, it means “ground monitoring point” in ground,
if the first letter is ‘k’, it means “aircraft”in air,
then R,A,P, described above.

Next an integer m, the amount of communication relationship.
Next m lines, each line is like x, B, y, C (1<=B, C<=n, x, y = ‘d’ or ‘k’), represents object B is communicated with object C, B’s type is x, C’s type is y; B,C is the sequence number in particular kind (‘d’ or ‘k’) listed above, starts from 1.
1<=n<=300, 0<=m<=n*n, 1<=dd,dk,kk<=10^6, R、A are floating numbers, 0<=R<=1000,
0<=A<2*PI, 1<=P<=10^6。
PS: communication between two points is considered as a segment.

Multiple cases, end with EOF;
The first line, 4 positive integers, n, dd, dk, kk, there is n aircrafts or ground monitoring points, dd, dk, kk is the same with description above. Remember that we first calculate the distance between two objects into integer, four to five homes in rounding, then calculate the communication cost price.

Next n lines, each represents an aircraft or ground monitoring point,
if the first letter is ‘d’, it means “ground monitoring point” in ground,
if the first letter is ‘k’, it means “aircraft”in air,
then R,A,P, described above.

Next an integer m, the amount of communication relationship.
Next m lines, each line is like x, B, y, C (1<=B, C<=n, x, y = ‘d’ or ‘k’), represents object B is communicated with object C, B’s type is x, C’s type is y; B,C is the sequence number in particular kind (‘d’ or ‘k’) listed above, starts from 1.
1<=n<=300, 0<=m<=n*n, 1<=dd,dk,kk<=10^6, R、A are floating numbers, 0<=R<=1000,
0<=A<2*PI, 1<=P<=10^6。
PS: communication between two points is considered as a segment.

2 1000 2000 3000
d 2 0 1
d 3 0 4
1
d 1 d 2

Case #1: 502.5000 2