#include <bits/stdc++.h>
using namespace std;
int n, m, k;
long long stx, sty;
long long Stx, Sty;
long long ans;
bool valid(long long r, long long c) {
  return (r >= 1 && c >= 1 && r <= n && c <= m);
}
int main() {
  cin >> n >> m >> stx >> sty >> k;
  for (int i = 0, ff, ss; i < k; i++) {
    cin >> ff >> ss;
    long long l = 0, r = 1e11, mi, j = -1;
    while (l <= r) {
      mi = (l + r) >> 1LL;
      Stx = stx + ff * mi;
      Sty = sty + ss * mi;
      if (valid(Stx, Sty)) {
        j = mi;
        l = mi + 1;
      } else {
        r = mi - 1;
      }
    }
    if (j != -1) {
      stx += ff * j;
      sty += ss * j;
      ans += j;
    }
  }
  cout << ans << "\n";
  return 0;
}
