#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  const long maxSteps = 1000000000;
  long n, m;
  cin >> n >> m;
  long x, y;
  cin >> x >> y;
  int k;
  cin >> k;
  long long total = 0;
  while (k--) {
    long dx = 0, dy = 0;
    cin >> dx >> dy;
    long stepsX = maxSteps, stepsY = maxSteps;
    if (dx > 0) {
      stepsX = (n - x) / dx;
    } else if (dx < 0) {
      stepsX = (x - 1) / -dx;
    }
    if (dy > 0) {
      stepsY = (m - y) / dy;
    } else if (dy < 0) {
      stepsY = (y - 1) / -dy;
    }
    long stepsnum = 0;
    if (stepsY > 0 && stepsX > 0) {
      stepsnum = min(stepsX, stepsY);
    }
    x += stepsnum * dx;
    y += stepsnum * dy;
    total += stepsnum;
  }
  cout << total;
  return 0;
}
