This page is still under construction.

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

Eco-driving

Time limit1sMemory limit128 MB

Summary
Find a route from junction 1 to J with total length at most D that minimizes the largest turn angle at any intermediate junction, and print that angle.
Level

Hard8 of 10

Topics
Graph, Binary search, Shortest path, Geometry
Solved
No attempts yet

Problem

My colleague Elisabeth is lazy — both at work and on her way to work. She never does more than necessary, and that includes her commute. Her goal is to spend as little energy as possible, which she achieves by braking and accelerating as little as she can. This applies to every wheeled vehicle she owns.

Elisabeth has already tuned her route by trial and error, but now she wants your help to find the optimal one. She gives you a map with JJ junctions and RR straight one-way roads between them. A two-way road is represented as two separate one-way roads.

Because Elisabeth often works night shifts, there is no other traffic on the roads, so she only needs to brake and accelerate when she turns at a junction. She wants a route on which the largest turning angle at any junction is as small as possible, because that lets her keep her speed up. However, the route must not be too long.

The turning angle at a junction is the angle between the direction of the road she arrives on and the direction of the road she leaves on. It ranges from 00 degrees (continuing straight ahead) to 180180 degrees (turning completely back). Taking the first road out of junction 11 requires no turn, and arriving at junction JJ ends the trip, so no turn is counted there.

Input

The first line contains three space-separated integers JJ, RR, DD (2≤J≤2002 \le J \le 200, 1≤R≤39 8001 \le R \le 39\,800, 1≤D≤1 000 0001 \le D \le 1\,000\,000): the number of junctions, the number of one-way roads, and the maximum distance in meters that Elisabeth is willing to travel. The road network is such that no path she might use has a length LL with D<L<D⋅(1+10−6)D < L < D \cdot (1 + 10^{-6}).

Then follow JJ lines, each with two integers XX and YY (−100 000≤X,Y≤100 000-100\,000 \le X, Y \le 100\,000): the distinct coordinates in meters of the junctions on flat ground. Elisabeth lives at junction 11 and works at junction JJ.

Then follow RR lines, each with two integers AA and BB (1≤A,B≤J1 \le A, B \le J), describing a one-way road from source junction AA to destination junction BB.

Output

Output a single line with the largest turning angle, in degrees, of the route whose largest turning angle is as small as possible, rounded to exactly 88 digits after the decimal point. If no route from junction 11 to junction JJ is short enough (total length at most DD), output Impossible instead.

Examples3

  1. Example 1

    Input
    5 6 500
    -100 0
    -100 100
    0 200
    100 100
    100 0
    1 2
    1 3
    2 3
    3 4
    3 5
    4 5
    
    Expected output
    90.00000000
    
  2. Example 2

    Input
    5 6 450
    -100 0
    -100 100
    0 200
    100 100
    100 0
    1 2
    1 3
    2 3
    3 4
    3 5
    4 5
    
    Expected output
    126.86989765
    
  3. Example 3

    Input
    5 12 440
    -100 0
    -100 100
    0 200
    100 100
    100 0
    1 2
    1 3
    3 1
    2 3
    3 2
    3 4
    4 3
    3 5
    5 3
    4 5
    5 4
    5 1
    
    Expected output
    Impossible