#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m, x, y, k;
  cin >> n >> m >> x >> y >> k;
  long long ans = 0;
  while (k--) {
    long long a, b;
    cin >> a >> b;
    long long l = 0, r = max(n, m);
    while (r - l > 1) {
      long long mid = (l + r) / 2;
      if (x + mid * a <= n && y + mid * b <= m && x + mid * a >= 1 &&
          y + mid * b >= 1) {
        l = mid;
      } else {
        r = mid;
      }
    }
    ans += l;
    x += l * a;
    y += l * b;
  }
  cout << ans;
}
