#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n, m, k;
  cin >> n >> m;
  long long ans = 0;
  long long x1, y1;
  cin >> x1 >> y1 >> k;
  for (long long i = 0; i < k; i++) {
    long long x, y;
    cin >> x >> y;
    long long steps =
        min(abs(x ? ((x > 0) ? (n - x1) / x : (x1 - 1) / x) : 1e9),
            abs(y ? ((y > 0) ? (m - y1) / y : (y1 - 1) / y) : 1e9));
    ans += steps;
    x1 += steps * x;
    y1 += steps * y;
  }
  cout << ans << endl;
  return 0;
}
