#include <bits/stdc++.h>
using namespace std;
void ret(string s) {
  cout << s;
  exit(0);
}
int main() {
  int x, y, vx, vy, m, n, k, kx, ky, kol;
  long long ans = 0;
  cin >> n >> m;
  cin >> x >> y >> k;
  for (int i = 0; i < k; i++) {
    cin >> vx >> vy;
    if (vx == 0) kx = 2000000000;
    if (vx > 0) kx = (n - x) / vx;
    if (vx < 0) kx = (1 - x) / vx;
    if (vy == 0) ky = 2000000000;
    if (vy > 0) ky = (m - y) / vy;
    if (vy < 0) ky = (1 - y) / vy;
    kol = min(kx, ky);
    ans += kol;
    x += vx * kol;
    y += vy * kol;
  }
  cout << ans;
  return 0;
}
