#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  long n, m, xc, yc, vecsize, x, y;
  long long steps = 0;
  cin >> n >> m >> xc >> yc >> vecsize;
  vector<pair<int, int> > vectors;
  vectors.resize(vecsize);
  for (int i = 0; i < vecsize; i++) {
    x = y = LONG_MAX;
    cin >> vectors[i].first >> vectors[i].second;
    if (vectors[i].first > 0) {
      x = (n - xc) / vectors[i].first;
    } else if (vectors[i].first < 0) {
      x = (xc - 1) / (vectors[i].first * -1);
    }
    if (vectors[i].second > 0) {
      y = (m - yc) / vectors[i].second;
    } else if (vectors[i].second < 0) {
      y = (yc - 1) / vectors[i].second * -1;
    }
    x = min(x, y);
    xc += x * vectors[i].first;
    yc += x * vectors[i].second;
    steps += x;
  }
  cout << steps;
  return 0;
}
