#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0LL) return a;
  return gcd(b, a % b);
}
long long bigmod(long long a, long long b, long long mod) {
  if (b == 0LL) return 1LL;
  long long sq = bigmod(a, b / 2LL, mod);
  sq = (sq * sq) % mod;
  if (b & 1LL) return (sq * (a % mod)) % mod;
  return sq;
}
const int inf = INT_MAX;
void solve() {
  long long n, m;
  cin >> n >> m;
  long long x, y;
  cin >> x >> y;
  long long k;
  cin >> k;
  long long dx, dy, ans = 0;
  for (int i = 0; i < k; i++) {
    cin >> dx >> dy;
    long long cx, cy;
    if (dx == 0)
      cx = inf;
    else if (dx > 0) {
      cx = (n - x) / dx;
    } else
      cx = (x - 1) / (-dx);
    if (dy == 0)
      cy = inf;
    else if (dy > 0) {
      cy = (m - y) / dy;
    } else
      cy = (y - 1) / (-dy);
    long long cur = min(cx, cy);
    x += cur * dx;
    y += cur * dy;
    ans += cur;
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
