#include <bits/stdc++.h>
using namespace std;
struct point {
  long long x, y;
};
long long n, m;
int val(point a) {
  if (a.x <= 0) return 0;
  if (a.y <= 0) return 0;
  if (a.x > n) return 0;
  if (a.y > m) return 0;
  return 1;
}
int a[100005], b[100005];
long long x, y;
int main() {
  cin >> n;
  cin >> m;
  point s;
  long long st = 0;
  cin >> s.x;
  cin >> s.y;
  int k, i;
  scanf("%d", &k);
  for (i = 0; i < k; i++) {
    cin >> x;
    cin >> y;
    point ne;
    ne.x = s.x + x;
    ne.y = s.y + y;
    if (val(ne)) {
      long long lo, mid, hi;
      lo = 0;
      hi = 1000000007;
      mid = lo;
      while (lo <= hi) {
        mid = (lo + hi) / 2;
        ne.x = s.x + mid * x;
        ne.y = s.y + mid * y;
        int res = val(ne);
        if (res == 0)
          hi = mid - 1;
        else {
          ne.x += x;
          ne.y += y;
          if (val(ne)) {
            lo = mid + 1;
          } else
            break;
        }
      }
      st += mid;
      s.x += mid * x;
      s.y += mid * y;
    }
  }
  cout << st;
}
