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.