The Temple

No attempts yetTime limit1sMemory limit128 MB

Problem

A team of archaeologists is about to start excavating an ancient temple, and the first task is to light up the site. The temple is a wide, flat floor on which many tall cylindrical columns stand. The team puts one power source and several lamps on the floor and wants to connect every lamp to the power source with the shortest possible wire. Find the length of each wire.

To keep the model simple, assume the following:

  • no two columns touch each other;
  • a wire has no thickness, must lie flat on the floor, and may touch a column but may never pass through it;
  • the power source and the lamps are treated as points and never touch a column.

Viewed from above, the columns are circles and the power source and lamps are points. For each lamp, write a program that computes the length of the shortest wire connecting it to the power source.

Input

The first line contains the number of columns nn (1n3001 \le n \le 300). Each of the next nn lines describes one column with three integers xx, yy, rr (1r50001 \le r \le 5000, rx,y10000rr \le x, y \le 10000 - r): the centre (x,y)(x, y) and the radius rr of the column. The next line contains the number of lamps mm (1m2001 \le m \le 200). Each of the next mm lines contains the coordinates xix_i, yiy_i (0xi,yi100000 \le x_i, y_i \le 10000) of one lamp. The last line contains the coordinates xax_a, yay_a (0xa,ya100000 \le x_a, y_a \le 10000) of the power source.

Output

Print mm lines. On the ii-th line, print the length of the shortest wire connecting the ii-th lamp to the power source, rounded to exactly six digits after the decimal point (such as 9.278662).

Hint

The figure illustrates a layout of columns and wires.