#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100001;
const int INF = 0x7FFFFFFF;
const double eps = 1e-10;
const double pi = acos(-1.0);
long long t, n, m, x, y, dx, dy;
int main() {
  cin >> n >> m;
  cin >> x >> y;
  long long ret = 0;
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> dx >> dy;
    long long MIN = INF;
    if (dx > 0) {
      MIN = min((n - x) / dx, MIN);
    } else if (dx < 0)
      MIN = min((x - 1) / -dx, MIN);
    if (dy > 0) {
      MIN = min((m - y) / dy, MIN);
    } else if (dy < 0)
      MIN = min((y - 1) / -dy, MIN);
    ret += MIN;
    x += dx * MIN;
    y += dy * MIN;
  }
  cout << ret << endl;
  return 0;
}
