#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e18 + 9;
void fast() { std::ios_base::sync_with_stdio(0); }
long long n, m;
bool valid(long long x, long long y) {
  return x > 0 && x <= n && y > 0 && y <= m;
}
int main() {
  cin >> n >> m;
  long long x, y;
  cin >> x >> y;
  long long k;
  cin >> k;
  long long tox, toy;
  long long ans = 0, steps;
  for (int i = 0; i < k; i++) {
    steps = 0;
    scanf("%lld%lld", &tox, &toy);
    long long l = 0, r = 1e9 + 9, mid;
    while (l <= r) {
      mid = l + (r - l) / 2;
      if (valid(x + (tox * mid), y + (toy * mid))) {
        steps = mid;
        l = mid + 1;
      } else {
        r = mid - 1;
      }
    }
    ans += steps;
    x = (tox * steps) + x;
    y = (toy * steps) + y;
  }
  cout << ans << endl;
  return 0;
}
