#include <bits/stdc++.h>
using namespace std;
const int oo = 1000000001;
long long n, m, p, x, y;
int main() {
  int i, j;
  long long s = 0, ii, jj;
  scanf("%d%d", &n, &m);
  scanf("%d%d", &x, &y);
  scanf("%d", &p);
  while (p--) {
    scanf("%d%d", &i, &j);
    ii = oo;
    if (i > 0)
      ii = (n - x) / i;
    else if (i < 0)
      ii = (x - 1) / i;
    jj = oo;
    if (j > 0)
      jj = (m - y) / j;
    else if (j < 0)
      jj = (y - 1) / j;
    ii = abs(ii);
    jj = abs(jj);
    ii = min(ii, jj);
    s += ii;
    x += ii * i;
    y += ii * j;
  }
  printf("%I64d\n", s);
  return 0;
}
