#include <bits/stdc++.h>
using namespace std;
long long i, j, k, l, m, n, x1[10010], v1[10010], xc, yc, xc1, yc1, z, step;
string s;
int main() {
  cin >> n >> m;
  cin >> xc >> yc;
  cin >> k;
  for (i = 1; i <= k; i++) cin >> x1[i] >> v1[i];
  for (i = 1; i <= k; i++) {
    if (x1[i] != 0 && v1[i] != 0) {
      if (x1[i] > 0) xc1 = (n - xc) / abs(x1[i]);
      if (x1[i] < 0) xc1 = (xc - 1) / abs(x1[i]);
      if (v1[i] > 0) yc1 = (m - yc) / v1[i];
      if (v1[i] < 0) yc1 = (yc - 1) / abs(v1[i]);
      z = min(abs(xc1), abs(yc1));
    }
    if (x1[i] == 0 && v1[i] > 0) z = (m - yc) / v1[i];
    if (x1[i] == 0 && v1[i] < 0) z = (yc - 1) / abs(v1[i]);
    if (v1[i] == 0 && x1[i] > 0) z = (n - xc) / x1[i];
    if (v1[i] == 0 && x1[i] < 0) z = (xc - 1) / abs(x1[i]);
    step += abs(z);
    xc += z * x1[i];
    yc += z * v1[i];
  }
  cout << step << endl;
  return 0;
}
