#include <bits/stdc++.h>
using namespace std;
int n, m, Xc, Yc, k, x, y, c, z;
long long ans, steps;
int cox(int a) {
  if (a > 0)
    return n;
  else
    return 1;
}
int coy(int b) {
  if (b > 0)
    return m;
  else
    return 1;
}
int main() {
  scanf("%d %d %d %d %d", &n, &m, &Xc, &Yc, &k);
  while (k--) {
    scanf("%d %d", &x, &y);
    if (x == 0 && y == 0) continue;
    if (x == 0) {
      c = coy(y);
      steps = abs(c - Yc) / abs(y);
      ans += steps;
      Yc += steps * y;
    } else if (y == 0) {
      z = cox(x);
      steps = abs(z - Xc) / abs(x);
      ans += steps;
      Xc += steps * x;
    } else {
      c = coy(y);
      z = cox(x);
      steps = min((abs(z - Xc) / abs(x)), (abs(c - Yc) / abs(y)));
      ans += steps;
      Xc += steps * x;
      Yc += steps * y;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
