#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T bigmod(T p, T e, T M) {
  long long ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
  return (a / gcd(a, b)) * b;
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
template <class T>
inline T bpow(T p, T e) {
  long long ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p);
    p = (p * p);
  }
  return (T)ret;
}
struct data {
  int ele1, ele2, ele3;
  data() {}
  data(int a, int b, int c) { ele1 = a, ele2 = b, ele3 = c; }
  bool friend operator<(data a, data b) { return a.ele1 > b.ele1; }
};
int n, m, k;
long long N, M, K;
int main() {
  int t, tc = 1;
  scanf("%d %d", &n, &m);
  int x, y;
  scanf("%d %d", &x, &y);
  long long step = 0;
  scanf("%d", &k);
  while (k--) {
    int dx, dy;
    scanf("%d %d", &dx, &dy);
    int p = 0, q = 0;
    if (dx < 0) {
      p = (x - 1) / dx;
    } else if (dx > 0) {
      p = (n - x) / dx;
    }
    if (dy < 0) {
      q = (y - 1) / dy;
    } else if (dy > 0) {
      q = (m - y) / dy;
    }
    p = abs(p);
    q = abs(q);
    int mn;
    if (dx == 0)
      mn = q;
    else if (dy == 0)
      mn = p;
    else {
      mn = min(p, q);
    }
    step += mn;
    x += mn * dx;
    y += mn * dy;
  }
  printf("%lld", step);
  return 0;
}
