This page is still under construction.

Parts of this page are still being built. What you see may change.

Walkie-talkie

Time limit1sMemory limit128 MB

Summary
Given a planar track network, find all cities Slawek can visit while Mirek positions himself elsewhere so they stay within distance d at all times.
Level

Hard8 of 10

Topics
Graph, Geometry, BFS, Shortest path
Solved
No attempts yet

Problem

Mirek and Sławek were recently hired as locomotive drivers at the national railway. On their very first day they are given an interesting assignment: each of them must start from a predetermined city and drive his locomotive through as many cities as possible.

Mirek is an experienced driver and is afraid of nothing. For Sławek it is the first time, so he cannot do anything with a train on his own. Fortunately every locomotive is equipped with a walkie-talkie, so Mirek can give Sławek instructions as long as the two of them stay within the range of the device.

Cities are represented by points in the plane. Some pairs of cities are joined by railway tracks, that is, by segments connecting the given points. Mirek and Sławek begin their journey in cities that are at most dd kilometers apart.

A locomotive may travel along the tracks in either direction and at any speed (it may also stop at any place), but it may switch to another track only at a city. At every moment Mirek and Sławek must be at most dd kilometers apart.

Write a program that finds every city Sławek can visit under the rules described above. The program should:

  • read from standard input the description of the railway network, the number dd, and the starting positions of Mirek and Sławek,
  • find the cities Sławek can reach,
  • write the result to standard output.

Input

The first line contains integers nn and mm (2≤n≤1002 \le n \le 100, 1≤m≤30001 \le m \le 3000) and a real number dd (1≤d≤100001 \le d \le 10000, dd has at most two digits after the decimal point). They denote, respectively, the number of cities, the number of track segments, and the range of the walkie-talkie in kilometers. Cities are numbered from 11 to nn. Each of the next nn lines contains the coordinates of a city xix_i, yiy_i (−5000≤xi,yi≤5000-5000 \le x_i, y_i \le 5000). The next mm lines describe the railway network; each of them contains two integers, the numbers of the two cities joined by a track segment. The last line contains the numbers of the cities where Mirek and Sławek start their journey, in that order. These two cities are at most dd kilometers apart.

Output

Print the numbers of the cities Sławek can reach. The numbers must be sorted in increasing order and printed one per line.

Examples2

  1. Example 1

    Input
    5 4 1.5
    0 1
    0 0
    4 1
    4 0
    2 2
    1 3
    1 5
    3 5
    2 4
    2 1
    
    Expected output
    1
    3
    
  2. Example 2

    Input
    4 2 2
    0 0
    10 0
    0 1
    10 1
    1 2
    3 4
    1 3
    
    Expected output
    3
    4