#include <bits/stdc++.h>
using namespace std;
long long m, n, k, cx, cy;
long long res;
string c = "Case";
void Solve(long long dx, long long dy) {
  int x = cx + dx, y = cy + dy;
  if (x >= 1 && x <= m && y >= 1 && y <= n) {
    if (x == cx && y < cy) {
      if (dy == 0) cout << "no1 " << '\n';
      long long t = abs((cy - 1) / dy);
      res += abs(t), cy += dy * abs(t);
    } else if (x == cx && y > cy) {
      if (dy == 0) cout << "no2 " << '\n';
      long long t = abs((n - cy) / dy);
      res += abs(t), cy += dy * abs(t);
    } else if (x > cx && y == cy) {
      if (dx == 0) cout << "no3 " << '\n';
      long long t = abs((m - cx) / dx);
      res += abs(t), cx += dx * abs(t);
    } else if (x < cx && y == cy) {
      if (dx == 0) cout << "no4 " << '\n';
      long long t = abs((cx - 1) / dx);
      res += abs(t), cx += dx * abs(t);
    } else if (x > cx && y > cy) {
      if (dy == 0 || dx == 0) cout << "no5 " << '\n';
      long long t = min(abs((m - cx) / dx), abs((n - cy) / dy));
      res += abs(t), cx += abs(t) * dx, cy += abs(t) * dy;
    } else if (x > cx && y < cy) {
      if (dy == 0 || dx == 0) cout << "no6 " << '\n';
      long long t = min(abs((m - cx) / dx), abs((cy - 1) / dy));
      res += abs(t), cx += abs(t) * dx, cy += abs(t) * dy;
    } else if (x < cx && y > cy) {
      if (dy == 0 || dx == 0) cout << "no7 " << '\n';
      long long t = min(abs((cx - 1) / dx), abs((n - cy) / dy));
      res += abs(t), cx += abs(t) * dx, cy += abs(t) * dy;
    } else if (x < cx && y < cy) {
      if (dy == 0 || dx == 0) cout << "no8 " << '\n';
      long long t = min(abs((cx - 1) / dx), abs((cy - 1) / dy));
      res += abs(t), cx += abs(t) * dx, cy += abs(t) * dy;
    }
  }
}
void Input() {
  cin >> m >> n >> cx >> cy;
  cin >> k;
  for (int i = 1; i <= k; i++) {
    long long u, v;
    cin >> u >> v;
    Solve(u, v);
  }
  cout << res << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  Input();
  return 0;
}
