#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, m, k;
int main() {
  cin >> n >> m;
  long long dx, dy, x, y;
  scanf("%lld%lld%d", &dx, &dy, &k);
  long long ans = 0;
  while (k--) {
    long long x, y;
    scanf("%lld%lld", &x, &y);
    long long l = 1, r = 1e9 + 5, res = 0;
    while (l <= r) {
      long long mid = (l + r) >> 1;
      if (dx + x * mid <= n && dy + y * mid <= m && dx + x * mid > 0 &&
          dy + y * mid > 0) {
        res = mid;
        l = mid + 1;
      } else
        r = mid - 1;
    }
    ans += res;
    dx += x * res;
    dy += y * res;
  }
  printf("%lld\n", ans);
  return 0;
}
