Slalom

Time limit1sMemory limit128 MB

Summary
Given gate pairs at increasing depths and S vertical speeds, find the smallest speed that lets a skier move horizontally fast enough to pass through every gate, and output it or IMPOSSIBLE.
Level

Medium7 of 10

Topics
Binary search, Math, Greedy, Implementation
Solved
No attempts yet

Problem

You are competing in a ski slalom and need to choose the best pair of skis for the race. The course consists of NN pairs of gates. Each pair has a left gate and a right gate, with the right gate exactly WW metres to the right of the corresponding left gate; you may never pass to the left of a left gate nor to the right of a right gate. The ii-th pair of gates lies at vertical distance yiy_i down the hill, and the horizontal position of its left gate is xix_i (so its right gate is at xi+Wx_i + W). Every gate is farther down the hill than the previous one, i.e. yi<yi+1y_i < y_{i+1} for all ii.

You may pick one of SS pairs of skis; the jj-th pair has speed sjs_j. If you use the skis with speed sjs_j, you descend at a constant vertical velocity of sjs_j metres per second. Separately, at any moment you may move horizontally at a speed of at most vhv_h metres per second. You may start and finish at any horizontal positions.

Determine which pair of skis lets you complete the course, passing through every gate, in the shortest time.

Input

The first line contains three integers WW, vhv_h, and NN, separated by spaces, with 1≤W≤1081 \le W \le 10^8, 1≤vh≤1061 \le v_h \le 10^6, and 1≤N≤1051 \le N \le 10^5.

Each of the next NN lines contains two integers xix_i and yiy_i: the horizontal and vertical positions of the ii-th left gate, with 1≤xi,yi≤1081 \le x_i, y_i \le 10^8.

The next line contains an integer SS, the number of ski pairs, with 1≤S≤1061 \le S \le 10^6.

Each of the next SS lines contains one integer sjs_j, the speed of the jj-th pair of skis, with 1≤sj≤1061 \le s_j \le 10^6.

Output

If no pair of skis can complete the course, print IMPOSSIBLE. Otherwise, print the vertical speed sjs_j of the pair of skis that completes the course in the shortest time.

Examples1

  1. Example 1

    Input
    3 2 3
    1 1
    5 2
    1 3
    3
    3
    2
    1
    
    Expected output
    2