#include <bits/stdc++.h>
using namespace std;
long long n, m, x, y, k, dx, dy, ans, dif;
int main() {
  for (cin >> n >> m >> x >> y >> k; k; k--) {
    cin >> dx >> dy;
    dif = 0;
    dif = min(!dx ? (long long)1e9 : ((dx < 0 ? 1 : n) - x) / dx,
              !dy ? (long long)1e9 : ((dy < 0 ? 1 : m) - y) / dy);
    ans += dif;
    x += dif * dx;
    y += dif * dy;
  }
  cout << ans;
  return 0;
}
