PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000373. Chọn ván trượt tuyết (Slalom 2)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Chọn ván trượt tuyết (Slalom 2)

Slalom 2

Source: Kattis

Version: Phuoc Hung OJ Extended

Problem Statement

A ski race has NN pairs of gates. Pair ii lies at downhill distance yiy_i metres; its left post has horizontal coordinate xix_i and its right post is WW metres farther right. Cross every pair in order at a horizontal coordinate in [xi,xi+W][x_i,x_i+W], including the endpoints. Among SS pairs of skis, pair jj gives constant downhill speed sjs_j metres per second. You may move sideways in either direction at speed at most vhv_h metres per second. Your initial and final horizontal positions are unrestricted. Select skis allowing all gates to be passed in the shortest time.

Path through the three gates in the example

Input

The first line contains integers W,vh,NW,v_h,N. Each of the next NN lines contains integers xi,yix_i,y_i. The next line contains integer SS. Each of the following SS lines contains integer sjs_j.

Output

Print the greatest integer speed among skis that can pass every gate. If none is feasible, print IMPOSSIBLE.

Subtasks

  • Subtask 1 (20 points): 1≤W≤1081\le W\le10^8; 1≤vh≤1061\le v_h\le10^6; 1≤N≤201\le N\le 20; 1≤xi,yi≤1081\le x_i,y_i\le10^8 (1≤i≤N1\le i\le N); 1≤S≤201\le S\le 20; 1≤sj≤1061\le s_j\le10^6 (1≤j≤S1\le j\le S). For every 1≤i<N1\le i<N, yi<yi+1y_i<y_{i+1}.
  • Subtask 2 (30 points): 1≤W≤1081\le W\le10^8; 1≤vh≤1061\le v_h\le10^6; 1≤N≤10001\le N\le 1000; 1≤xi,yi≤1081\le x_i,y_i\le10^8 (1≤i≤N1\le i\le N); 1≤S≤20001\le S\le 2000; 1≤sj≤1061\le s_j\le10^6 (1≤j≤S1\le j\le S). For every 1≤i<N1\le i<N, yi<yi+1y_i<y_{i+1}.
  • Subtask 3 (50 points): 1≤W≤1081\le W\le10^8; 1≤vh≤1061\le v_h\le10^6; 1≤N≤1000001\le N\le 100000; 1≤xi,yi≤1081\le x_i,y_i\le10^8 (1≤i≤N1\le i\le N); 1≤S≤10000001\le S\le 1000000; 1≤sj≤1061\le s_j\le10^6 (1≤j≤S1\le j\le S). For every 1≤i<N1\le i<N, yi<yi+1y_i<y_{i+1}.

Examples

Input

3 2 3
1 1
5 2
1 3
3
3
2
1

Output

2

Explanation

The intervals are [1,4],[5,8],[1,4][1,4],[5,8],[1,4]. Speed 2 allows 0.5 seconds per transition and 1 metre of lateral movement. Positions 4,5,4 are feasible. Speed 3 only allows 2/32/3 metre, too little for the second gate.

Input

3 2 3
1 1
5 2
1 3
1
3

Output

IMPOSSIBLE

Explanation

Only speed 3 is offered. The first two gates are at least 1 metre apart horizontally, beyond the allowed 2/32/3 metre.

Input

1 1 3
1 1
3 2
5 3
2
1
2

Output

IMPOSSIBLE

Explanation

The three intervals are [1,2],[3,4],[5,6][1,2],[3,4],[5,6]. At speed 1 total lateral movement is at most 2 metres between the first and last gate, less than the required 3. Speed 2 is even less feasible.