#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, x, y, k, c, c1, mx = 0;
  cin >> n >> m >> x >> y >> k;
  for (int i = 1; i <= k; i++) {
    cin >> c >> c1;
    long long l = 1, r = 1e9, ans, mid;
    while (l <= r) {
      mid = (l + r) / 2;
      if ((c * mid) + x > 0 && c * mid + x <= n && c1 * mid + y > 0 &&
          c1 * mid + y <= m) {
        l = mid + 1;
        ans = mid;
      } else {
        r = mid - 1;
      }
    }
    x += c * ans;
    y += c1 * ans;
    mx += ans;
    ans = 0;
  }
  cout << mx;
}
