#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  long long x, y, dx, dy;
  cin >> x >> y;
  long long k;
  cin >> k;
  long long steps = 0, ans = 0, sx, sy;
  while (k--) {
    cin >> dx >> dy;
    if (dx > 0) sx = (n - x) / dx;
    if (dx < 0) sx = (x - 1) / abs(dx);
    if (dx == 0) sx = 2000000000;
    if (dy > 0) sy = (m - y) / dy;
    if (dy < 0) sy = (y - 1) / abs(dy);
    if (dy == 0) sy = 2000000000;
    steps = min(sx, sy);
    x += steps * dx;
    y += steps * dy;
    ans += steps;
  }
  cout << ans << endl;
  return 0;
}
