#include <bits/stdc++.h>
using namespace std;
int ipow(int base, int exp) {
  int result = 1;
  for (;;) {
    if (exp & 1) result *= base;
    exp >>= 1;
    if (!exp) break;
    base *= base;
  }
  return result;
}
void show(int a[], int array_size) {
  for (int i = 0; i < array_size; ++i) cout << a[i] << " ";
  cout << '\n';
}
int cc(int target, int q, int current) {
  if (q == 0) {
    if (target == current)
      return 1;
    else
      return 0;
  } else
    return (cc(target, q - 1, current + 1) + cc(target, q - 1, current - 1));
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int x, y;
  cin >> x >> y;
  int v, i;
  cin >> v;
  long long o = 0;
  for (i = 0; i < v; i++) {
    int x1, y1, X, Y;
    cin >> x1 >> y1;
    if (x1 == 0)
      X = 1000000005;
    else
      X = max((1 - x) / x1, (n - x) / x1);
    if (y1 == 0)
      Y = 1000000005;
    else
      Y = max((1 - y) / y1, (m - y) / y1);
    int d = min(X, Y);
    o = o + (long long)d;
    x += d * x1;
    y += d * y1;
  }
  cout << o << '\n';
  return 0;
}
