#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  long long x, y;
  cin >> x >> y;
  long long q;
  cin >> q;
  long long ans = 0;
  while (q--) {
    long long a, b;
    cin >> a >> b;
    long long u = 0;
    if (a != 0) {
      if (a >= 0) {
        u = (n - x) / a;
      } else {
        u = (1 - x) / a;
      }
    }
    long long h = 0;
    if (b != 0) {
      if (b >= 0) {
        h = (m - y) / b;
      } else {
        h = (1 - y) / b;
      }
    }
    long long an = min(h, u);
    if (a == 0 && b != 0 || b == 0 && a != 0) {
      an = max(h, u);
    }
    ans += an;
    x = (x + (an * a));
    y = (y + (an * b));
  }
  cout << ans << endl;
  return 0;
}
