#include <bits/stdc++.h>
using namespace std;
long long n, m;
bool valid(long long x, long long y) {
  return (x > 0) && (x <= n) && (y > 0) && (y <= m);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  long long res = 0;
  long long sx, sy, a, b;
  cin >> sx >> sy;
  int k;
  cin >> k;
  for (int i = 0; i < k; ++i) {
    cin >> a >> b;
    long long min_cnt = INT_MAX;
    if (a < 0) {
      min_cnt = min(min_cnt, (sx - 1) / abs(a));
    } else if (a > 0) {
      min_cnt = min(min_cnt, (n - sx) / a);
    }
    if (b < 0) {
      min_cnt = min(min_cnt, (sy - 1) / abs(b));
    } else if (b > 0) {
      min_cnt = min(min_cnt, (m - sy) / b);
    }
    sx += min_cnt * a;
    sy += min_cnt * b;
    res += min_cnt;
  }
  cout << res << endl;
  return 0;
}
