#include <bits/stdc++.h>
using namespace std;
long long n, m, inf = 1000000001;
int main() {
  cin >> n >> m;
  long long xc, yc;
  cin >> xc >> yc;
  long long k;
  cin >> k;
  long long ans = 0, dx, dy, s;
  for (int i = 0; i < k; i++) {
    cin >> dx >> dy;
    s = 0;
    if (dx < 0) {
      s = -(xc - 1) / dx;
    } else if (dx > 0 && n - xc >= dx) {
      s = (n - xc) / dx;
    } else if (dx == 0) {
      s = inf;
    }
    if (dy < 0) {
      s = min(s, -(yc - 1) / dy);
    } else if (dy > 0 && m - yc >= dy) {
      s = min(s, (m - yc) / dy);
    } else if (m - yc < dy) {
      s = 0;
    }
    if (s < 0) s = 0;
    xc += s * dx;
    yc += s * dy;
    ans += s;
  }
  cout << ans;
  return 0;
}
