#include <bits/stdc++.h>
using namespace std;
long long n, m, x, y, k, dx, dy, ans;
long long bs() {
  long long l = 0, r = 1000000000;
  while (l < r) {
    long long mid = (l + r) / 2;
    long long a = x + dx * mid, b = y + dy * mid;
    if (a < 1 || a > n || b < 1 || b > m)
      r = mid;
    else
      l = mid + 1;
  }
  return r - 1;
}
int main() {
  cin >> n >> m >> x >> y >> k;
  for (long long i = 1; i <= k; i++) {
    cin >> dx >> dy;
    long long s = bs();
    ans += s;
    x += dx * s;
    y += dy * s;
  }
  cout << ans;
  return 0;
}
