ELEC - Electrical Engineering


The electrical engineers’ indefatigable strive towards environmentally friendly energy production translated into the recent boom of hydro, solar, wind and geothermal power plants. While the production side seems ready, these ambitious projects have their bottleneck in the transportation and distribution: Besides the energy losses that occur during transportation over long distances, the renewable energy sources cannot provide power on demand – they must be taken as provided by nature. Used at large scale in today’s networks, unreliable green energy can disrupt the balance of power grids easily and cause huge damage along with large-scale power outages.

Serious effort is thus put on researching transient and dynamic phenomena in power grids. You are offered a position in the lab for linear and planar distribution networks. Given a description of the distribution network’s line impedances Zi , you are to find the equivalent impedance between some couples of nodes. The knowledge of such equivalent impedances may speed up the network analysis considerably! Impedances are complex number whose real part represents the resistive line behaviour while the imaginary part stands for the capacitive (negative) or inductive (positive) characteristic. Lines are bidirectional, that is impedance(a,b) equals impedance (b,a).

It was proven that any linear and planar graph (can be drawn in a way that its edges intersect only at their endpoints) can be reduced into a single equivalent edge that represents the equivalent impedance between its ending nodes, using the following six transformations:

Now that you have all the necessary operations available, are you able to determine the equivalent impedance between several couples of nodes?

Input

The input consists of several test-cases separated by an empty line. Each test-case starts with the number of nodes N (1<=N<=100), the number of bidirectional connections C (0<=C<=1000) and the number of equivalent impedances to compute Z (0<=Z<=10) on a line. Then follow C lines, each describing one bidirectional connection in the form ‘EndPoint_1’ ‘EndPoint_2’ ‘Impedance’. ‘EndPoint_1’ and ‘EndPoint_2’ are in the range 1 to N and impedance has the format ‘re im’ where re and im designate the real and imaginary parts respectively, both being real numbers d such that 10-3 < |d| < 103. The next Z lines each hold two integers, the indices of the nodes between which you are to compute the equivalent impedance. Input terminates on a test-case with N=C=Z=0, which must not be evaluated.

Output

For each couple of endpoints, output the equivalent impedance in the form ‘re im’ where re and im designate the real and imaginary parts respectively. If the nodes are not connected, output ‘no connection’. Electrical engineers will consider your result as correct if the absolute error on the real and imaginary parts is below 10-2. Finish each test-case on a blank line.

Sample

Input:
5 10 3
3 1 12.317 -0.779
5 3 30.107 0.289
5 1 27.447 -22.649
4 2 15.351 24.371
5 5 19.63 -3.549
2 2 11.841 18.757
4 5 4.834 -16.542
3 5 5.022 -22.387
2 5 24.768 -22.356
5 2 27.351 12.053
1 2
2 3
3 3

10 10 4
9 8 6.36 17.411
1 3 27.596 -6.484
9 10 4.735 -8.282
8 8 6.901 27.939
8 4 14.894 3.729
5 4 14.311 -2.422
10 10 11.009 6.225
4 4 3.196 -32.703
10 9 15.282 -14.799
3 9 20.473 27.158
10 9
8 1
2 9
9 6

Output:
23.37 -7.26
19.61 -6.97
0.00 0.00

3.79 -5.46
54.43 38.09
no connection
no connection

         

Sample input 1                                      Sample input 2



Added by:Christian Kauth
Date:2010-10-25
Time limit:3s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64