#include <bits/stdc++.h>
using namespace std;
long long n, m, k, xc, yc, x, y, nx, ny, t;
long long res;
int main() {
  long long c = 1000;
  c = c * c * c * c;
  cin >> n >> m >> xc >> yc >> k;
  for (long long i = 0; i < k; i++) {
    cin >> x >> y;
    if (x == 0) nx = c;
    if (x > 0) nx = (n - xc) / x;
    if (x < 0) nx = (xc - 1) / (-x);
    if (y == 0) ny = c;
    if (y > 0) ny = (m - yc) / y;
    if (y < 0) ny = (yc - 1) / (-y);
    t = min(nx, ny);
    res += t;
    xc += t * x;
    yc += t * y;
  }
  cout << res;
  return 0;
}
