Plotter
Pete’s parents got him the Mindrack 2.0 kit for building robots. Pete read the manual and decided to build a simple plotter to draw shapes. The plotter is a mechanical arm consisting of two segments with rotary joint and a slot for a pencil in the distal end. The arm is attached to a base using a joint too. Additionally the arm has servos that can rotate it relative to the base and turn segments relative to each other. The arm can draw various shapes on paper. Below is a schematic illustration:
Pete wrote a program that allows drawing various closed polylines based on a given set of points by means of coordinated actions of the servos. The arm can draw a polyline without taking the pencil off the paper. The only problem Pete has encountered is the limited mobility of the arm segments. The basal joint can turn no more than φ degrees left and right relative to its central position and the joint connecting the segments cannot turn more than θ degrees relative to the codirectional alignment of the segments. For that reason a situation can occur during drawing shapes when the robotic arm is unable to continue drawing without lifting the pencil from paper. In this case Pete has to disconnect the pencil manually, switch the arm into a new configuration and reconnect the pencil. The arm then continues drawing the polyline from the same point where it has ended drawing before manual switching. Naturally, Pete wants to minimize the amount of such manual switches.
Let the arm be positioned in the Oxy, reference plane and attached to its origin. Then the centra position of the arm is directed along the Oy. axis. Assume the arm consists of two segments with the lengths L and l, corresponding to the basal segment attached to the base and distal segment holding the pencil. Given the parameters of the arm — the numbers L, l, φ and θ, and coordinates of polyline points on the plane you have to calculate the minimal number of manual arm switches necessary to draw the polyline or determine that it is impossible. The arm can begin drawing from any point of the polyline and in any of the two directions. However, once the start point and the drawing direction have been selected the latter cannot be changed. In case of the switch, the arm must continue drawing from the same point where switching has occurred and in the same direction as before. If the polyline has self-intersections or self-contacts, then the arm is not allowed to switch to another polyline part at such points, it still must draw polyline segments in the prescribed order taking into account the chosen direction and starting point.
Input
The first line of the input file contains four nonnegative numbers — L, l, φ and θ (1 ≤ L + l ≤ 10^4, φ + θ ≤ 180). The next line contains an integer N — the number of points in the closed polyline (3 ≤ N ≤ 100000). The next N lines contain pairs of integers x_i and y_i – Cartesian coordinates of the polyline points. The absolute values of coordinates do not exceed 10^4. No two points coincide. It is assumed that the polyline consists of the segments (x_1,y_1)−(x_2, y_2), (x_2, y_2)−(x_3, y_3), …, (x_{N−1}, y_{N−1})−(x_N, y_N) и (x_N, y_N)−(x_1, y_1).
Output
The single line of the output file must contain the minimal number of manual switches of the arm necessary to draw the given polyline, or the number –1 if it is impossible to draw the polyline using the method described above.