Problem C. Comparison of graph layouts

Author:A. Baranov   Time limit:1 sec
Input file:Standard input   Memory limit:256 Mb
Output file:Standard output  

Statement

Young programmer Vasya is engaged in N-dimensional graph layout. As a result of the work of his algorithm, each vertex is assigned coordinates in the N-dimensional space. However, he did not take into account that the accuracy may be lost when the results are saved in different formats. Now he must examine files to determine which of them contains which graph.

We are given two graphs — original one and one read from file. Due to conversion vertex coordinates of the second graph may be shifted, but no more than by a given ε. Vertex indexing may be changed as well.

It is required to compare given graphs and reconstruct correspondence between their vertices if possible.

Input format

Input data contains integer N — dimension of the space, V — number of vertices and E — number of edges.

Following is a set of the N ⋅ V coordinates of vertices of the original graph and set of the E edges specified by index pairs. Vertices are indexed from zero.

Next the second graph is given in the same format.

The ε precision is the last item of the input.

Output format

Output data must contain V integers Li — index of the second graph vertex corresponding to i-th vertex of the original graph.

If it is not possible to restore correspondences, the output a single number  − 1.

Constraints

Distance between any pair of vertices of the original graph is no less than 10 ⋅ ε, and all coordinates are in the range from  − 10 to 10.

1 ≤ N ≤ 5, 1 ≤ V ≤ 2 ⋅ 104, 0 ≤ E ≤ 2 ⋅ V,

10 − 6 ≤ ε ≤ 1

Sample tests

No. Standard input Standard output
1
3 4 5

-1.15000  3.50000 -5.03000
-5.67000  9.10000  6.10000
 4.20000  3.65000 -4.23000
 1.05000  3.50000 -5.00000

0 1
1 2
2 3
3 0
0 2

-5.67040  9.10372  6.10903
 1.05189  3.50070 -5.00731
-1.15060  3.50870 -5.03701
 4.20300  3.65001 -4.23079

0 3
2 0
3 1
2 3
1 2

0.1
2
0
3
1
2
3 4 5

-1.15000  3.50000 -5.03000
-5.67000  9.10000  6.10000
 4.20000  3.65000 -4.23000
 1.05000  3.50000 -5.00000

0 1
1 2
2 3
3 0
0 2

-5.67040  9.10372  6.10903
 1.05189  3.50070 -5.00731
-1.15060  3.50870 -5.03701
 4.20300  3.65001 -4.23079

0 3
2 0
3 1
0 1
1 2

0.1
-1

0.102s 0.014s 13