#include <bits/stdc++.h>
using namespace std;
long long x, y;
int main() {
  long long n, m, x0, y0, k, x1, y1, i, t1, t2, t;
  while (cin >> n >> m) {
    cin >> x0 >> y0 >> k;
    long long step = 0;
    for (i = 0; i < k; i++) {
      cin >> x >> y;
      if (x >= 1) {
        if (y >= 1) {
          x1 = n - x0;
          y1 = m - y0;
        } else {
          x1 = n - x0;
          y1 = y0 - 1;
        }
      } else {
        if (y >= 0) {
          x1 = x0 - 1;
          y1 = m - y0;
        } else {
          x1 = x0 - 1;
          y1 = y0 - 1;
        }
      }
      if (x == 0) {
        t = abs(y1 / y);
        y0 += t * y;
        step += t;
      } else if (y == 0) {
        t = abs(x1 / x);
        x0 += t * x;
        step += t;
      } else {
        t1 = abs(x1 / x);
        t2 = abs(y1 / y);
        t = min(t1, t2);
        x0 += t * x;
        y0 += t * y;
        step += t;
      }
    }
    cout << step << endl;
  }
  return 0;
}
