Particle Swapping

No attempts yetTime limit5sMemory limit256 MB

Problem

A research team is preparing an experiment in particle physics. On a flat plate they have built a system of nn nodes joined by wires. The wires may cross each other on the plate.

When the experiment starts, a pair of particles appears at two different nodes. One ordinary matter particle appears at node AA, and the matching antimatter particle appears at node BB. The goal is to swap the two particles, that is, to reach the state where the matter particle is at node BB and the antiparticle is at node AA. The experiment runs as a sequence of moves. One move sends one of the two particles from the node it occupies to a neighbouring node along a wire.

Matter and antimatter annihilate when they get too close, which destroys the whole experiment. The team therefore wants a swap in which the smallest Euclidean distance between the two particles is as large as possible. That smallest distance is the safeness of the experiment. While a particle travels along a wire its position does not count, so the only risky moments are the moments when both particles are at nodes.

The physicists do not know yet where the particles will appear. They have written down \ell candidate pairs of starting nodes (A,B)(A, B), and for each candidate they want the largest safeness they can achieve.

Input

The first line contains an integer nn (1n5001 \le n \le 500), the number of nodes. Each of the next nn lines contains two integers xx and yy (10000x,y10000-10000 \le x, y \le 10000), the coordinates of one node on the plate, given in order from node 1 to node nn. No two nodes are at the same point.

The next line contains an integer mm (0m20000 \le m \le 2000), the number of wires. Each of the next mm lines contains two integers aa and bb (1a,bn1 \le a, b \le n, aba \ne b), meaning that a wire joins node aa and node bb. At most one wire joins any two nodes, and no wire joins a node to itself.

The next line contains an integer \ell (1(n2)1 \le \ell \le \binom{n}{2}), the length of the candidate list. Each of the next \ell lines contains two integers aa and bb (1a,bn1 \le a, b \le n, aba \ne b), the indices of the starting nodes AA and BB. Every listed pair admits a swap with positive safeness, so the two particles never have to occupy the same node.

Output

Print \ell lines. Line ii holds the largest safeness achievable for the ii-th pair on the list, written with exactly 8 digits after the decimal point and rounded to the nearest value at that precision. Every achievable safeness is the distance between two nodes, so each answer is the square root of an integer.