#include <bits/stdc++.h>
using namespace std;
long long int x, y, steps, n, m;
bool valid(long long int _x, long long int _y) {
  return (_x > n || _x <= 0 || _y > m || _y <= 0);
}
bool check(long long int mid, long long int dx, long long int dy) {
  if (!valid(dx * mid + x, dy * mid + y)) return true;
  return false;
}
int main() {
  cin >> n >> m >> x >> y;
  long long int t;
  cin >> t;
  while (t--) {
    long long int dx, dy;
    cin >> dx >> dy;
    long long int l = 1, r = 1e9, mid, ans = -1e10;
    while (l <= r) {
      mid = (l + r) / 2;
      if (check(mid, dx, dy)) {
        ans = max(mid, ans);
        l = mid + 1;
      } else
        r = mid - 1;
    }
    if (ans != -1e10) x = x + (dx * ans), y = y + (dy * ans), steps += ans;
  }
  cout << steps;
  return 0;
}
