One day Vasya went out for a walk in the yard but there weren't any of his friends outside and he had no one to play touch and run. But the boy didn't lose the high spirits and decided to play touch and run with himself. You may ask: "How did he do that?" The answer is simple.

Vasya noticed that the yard is a rectangular *n* × *m* field. The squares have coordinates (*x*, *y*) (1 ≤ *x* ≤ *n*, 1 ≤ *y* ≤ *m*), where *x* is the index of the row and *y* is the index of the column.

Initially Vasya stands in the square with coordinates (*x*<sub class="lower-index">*c*</sub>, *y*<sub class="lower-index">*c*</sub>). To play, he has got a list of *k* vectors (*dx*<sub class="lower-index">*i*</sub>, *dy*<sub class="lower-index">*i*</sub>) of non-zero length. The game goes like this. The boy considers all vectors in the order from 1 to *k*, and consecutively chooses each vector as the current one. After the boy has chosen a current vector, he makes the maximally possible number of valid steps in the vector's direction (it is possible that he makes zero steps).

A step is defined as one movement from the square where the boy is standing now, in the direction of the current vector. That is, if Vasya is positioned in square (*x*, *y*), and the current vector is (*dx*, *dy*), one step moves Vasya to square (*x* + *dx*, *y* + *dy*). A step is considered valid, if the boy does not go out of the yard if he performs the step.

Vasya stepped on and on, on and on until he ran out of vectors in his list. Ha had been stepping for so long that he completely forgot how many steps he had made. Help the boy and count how many steps he had made.
The first input line contains two integers *n* and *m* (1 ≤ *n*, *m* ≤ 10<sup class="upper-index">9</sup>) — the yard's sizes. The second line contains integers *x*<sub class="lower-index">*c*</sub> and *y*<sub class="lower-index">*c*</sub> — the initial square's coordinates (1 ≤ *x*<sub class="lower-index">*c*</sub> ≤ *n*, 1 ≤ *y*<sub class="lower-index">*c*</sub> ≤ *m*).

The third line contains an integer *k* (1 ≤ *k* ≤ 10<sup class="upper-index">4</sup>) — the number of vectors. Then follow *k* lines, each of them contains two integers *dx*<sub class="lower-index">*i*</sub> and *dy*<sub class="lower-index">*i*</sub> (|*dx*<sub class="lower-index">*i*</sub>|, |*dy*<sub class="lower-index">*i*</sub>| ≤ 10<sup class="upper-index">9</sup>, |*dx*| + |*dy*| ≥ 1).
4 5
1 1
3
1 1
1 1
0 -2
4
10 10
1 2
1
-1 0
0
10 20
10 3
10
-2 -6
-1 0
-8 0
0 5
-1 3
16 -16
-1 9
0 -18
9 -1
-9 5
13
20 10
14 4
10
6 0
-7 -7
12 -2
-4 9
20 3
-1 -16
0 2
-1 1
20 0
-1 1
4
1000 2000
226 566
20
0 -100
-100 100
100 0
42 0
-100 -79
-66 -16
0 -7
-1 0
0 100
100 91
99 0
1 0
-100 0
70 -100
-100 100
100 1
66 0
-100 1
-47 -100
-42 0
708
1 1
1 1
1
1 1
0
3 3
2 2
1
2 0
0
def read():
    return map(int, input().split())


def make_step(pos, end, d):
    if d > 0:
        res = (end - pos) // d
    elif d < 0:
        res = - (pos - 1) // d
    else:
        res = float('infinity')

    return res


def main():
    n, m = read()
    xc, yc = read()
    k = int(input())
    ans = 0
    for _ in range(k):
        dx, dy = read()
        stepx = make_step(xc, m, dx)
        stepy = make_step(yc, n, dy)
        num_steps = min(stepx, stepy)
        ans += num_steps
        xc += num_steps * dx
        yc += num_steps * dy

    print(ans)


if __name__ == "__main__":
    main()
