#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
int dblcmp(double d) {
  if (fabs(d) < eps) return 0;
  return d > eps ? 1 : -1;
}
const double PI = 3.1415926535897932384626433832795;
const double pi = acos(-1.0);
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
long long calc_steps(long long n, long long xs, long long dx) {
  if (dx == 0)
    return (long long)1000000002;
  else if (dx < 0)
    return (1 - xs) / dx;
  else
    return (n - xs) / dx;
}
long long could_go(long long n, long long m, long long xs, long long ys,
                   long long dx, long long dy) {
  long long s1 = calc_steps(n, xs, dx);
  long long s2 = calc_steps(m, ys, dy);
  return min(s1, s2);
}
int main(int argc, char* argv[]) {
  long long n, m, xc, yc, k, count = 0;
  cin >> n >> m;
  cin >> xc >> yc;
  long long xn = xc;
  long long yn = yc;
  cin >> k;
  for (long long i = 1; i <= k; i++) {
    long long dx, dy;
    cin >> dx >> dy;
    long long st = could_go(n, m, xn, yn, dx, dy);
    count += st;
    xn += dx * st;
    yn += dy * st;
  }
  cout << count;
  return 0;
}
