#include <bits/stdc++.h>
using namespace std;
long long n, m;
int main() {
  scanf("%lld%lld", &n, &m);
  long long xo, yo;
  scanf("%lld%lld", &xo, &yo);
  int q;
  scanf("%d", &q);
  long long solve = 0;
  while (q--) {
    long long x, y;
    scanf("%lld%lld", &x, &y);
    long long steps = 100000000000ll;
    if (x == 0 && y == 0) continue;
    if (x > 0) {
      steps = (n - xo) / x;
    } else if (x < 0) {
      steps = (xo - 1) / (abs(x));
    }
    if (y > 0) {
      steps = min(steps, (m - yo) / y);
    } else if (y < 0) {
      steps = min(steps, (yo - 1) / (abs(y)));
    }
    solve += steps;
    xo += steps * x;
    yo += steps * y;
  }
  printf("%lld\n", solve);
}
