#include <bits/stdc++.h>
using namespace std;
long long dx[10020], dy[10020];
int main(void) {
  long long n, m;
  long long x, y;
  int k;
  int i;
  long long tx, ty, t, o;
  scanf("%I64d %I64d", &n, &m);
  scanf("%I64d %I64d", &x, &y);
  scanf("%d", &k);
  for (i = 0; i < k; i++) scanf("%I64d %I64d", &dx[i], &dy[i]);
  for (i = o = 0; i < k; i++) {
    tx = 10000000020LL;
    if (dx[i] < 0) tx = (x - 1) / -dx[i];
    if (dx[i] > 0) tx = (n - x) / dx[i];
    ty = 10000000020LL;
    if (dy[i] < 0) ty = (y - 1) / -dy[i];
    if (dy[i] > 0) ty = (m - y) / dy[i];
    t = min(tx, ty);
    x += dx[i] * t;
    y += dy[i] * t;
    o += t;
  }
  printf("%I64d\n", o);
  return 0;
}
