#include <bits/stdc++.h>
using namespace std;
const int Size = 1e5;
long long n, m;
bool onField(long long x, long long y) {
  return (x <= n && x >= 1) && (y <= m && y >= 1);
}
int main() {
  long long x, y, dx, dy, k;
  long long ans = 0;
  cin >> n >> m;
  cin >> x >> y;
  cin >> k;
  for (int i = 0; i < k; i++) {
    cin >> dx >> dy;
    for (long long cof = 1100000000; cof; cof /= 2)
      while (onField(x + (cof * dx), y + (cof * dy))) {
        x += (cof * dx);
        y += (cof * dy);
        ans += cof;
      }
  }
  cout << ans << "\n";
  return 0;
}
