#include <bits/stdc++.h>
using namespace std;
struct comp {
  bool operator()(const pair<int, int> &a, const pair<int, int> &b) {
    return a.second > b.second;
  }
};
struct myclass {
  bool operator()(const pair<int, int> &a, const pair<int, int> &b) {
    return a.first > b.first;
  }
} myobject;
inline void in(int &n) {
  n = 0;
  int ch = getchar();
  int sign = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') sign = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    n = (n << 3) + (n << 1) + ch - '0', ch = getchar();
  }
  n = n * sign;
}
int main() {
  long long n, m, x, y, k, p, q, steps;
  int i;
  cin >> n >> m >> x >> y;
  cin >> k;
  long long ans = 0;
  for (i = 1; i <= k; i++) {
    cin >> p >> q;
    steps = 2000000001;
    if (p > 0) {
      steps = min(steps, (n - x) / p);
    } else if (p < 0) {
      steps = min(steps, (1 - x) / p);
    }
    if (q > 0) {
      steps = min(steps, (m - y) / q);
    } else if (q < 0) {
      steps = min(steps, (1 - y) / q);
    }
    if (steps != 2000000001) {
      x = x + steps * p;
      y = y + steps * q;
      ans = ans + steps;
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
