#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  long long n, m;
  cin >> n >> m;
  long long cx, cy;
  cin >> cx >> cy;
  long long k;
  cin >> k;
  int dx, dy;
  long def = 0;
  long long tmp1, tmp2;
  long long countStep = 0;
  int maxtmp = 0;
  long dm;
  for (int i = 0; i < k; i++) {
    cin >> dx >> dy;
    if (dx < 0) {
      tmp1 = (cx - 1) / dx;
    } else if (dx > 0) {
      tmp1 = (n - cx) / dx;
    }
    if (dy < 0) {
      tmp2 = (1 - cy) / dy;
    } else if (dy > 0) {
      tmp2 = (m - cy) / dy;
    }
    tmp1 = abs(tmp1);
    tmp2 = abs(tmp2);
    if (!dx) {
      dm = tmp2;
    } else if (!dy)
      dm = tmp1;
    else
      dm = min(tmp1, tmp2);
    countStep += dm;
    cx += dm * dx;
    cy += dm * dy;
  }
  cout << countStep;
  return 0;
}
