#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, m;
  cin >> n >> m;
  long long xc, yc;
  cin >> xc >> yc;
  int l;
  cin >> l;
  long long count = 0;
  for (int i = 0; i < l; i++) {
    long long a, b;
    cin >> a >> b;
    long long steps = 0;
    long long mid;
    long long l = 0, r = 1e9 + 9;
    while (l <= r) {
      mid = l + (r - l) / 2;
      if (xc + a * mid > 0 && xc + a * mid <= n && yc + b * mid > 0 &&
          yc + b * mid <= m) {
        steps = mid;
        l = mid + 1;
      } else {
        r = mid - 1;
      }
    }
    xc += steps * a;
    yc += steps * b;
    count += steps;
  }
  cout << count;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
