#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  cout.precision(10);
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  int k;
  cin >> k;
  vector<pair<int, int> > arr;
  for (int i = 0; i < k; i++) {
    int a, b;
    cin >> a >> b;
    arr.emplace_back(a, b);
  }
  long long sol = 0ll;
  for (int i = 0; i < k; i++) {
    int step = INT_MAX;
    if (arr[i].first < 0) {
      step = min(step, (x - 1) / abs(arr[i].first));
    } else if (arr[i].first > 0) {
      step = min(step, (n - x) / arr[i].first);
    }
    if (arr[i].second < 0) {
      step = min(step, (y - 1) / abs(arr[i].second));
    } else if (arr[i].second > 0) {
      step = min(step, (m - y) / arr[i].second);
    }
    sol += step;
    x += step * arr[i].first;
    y += step * arr[i].second;
  }
  cout << sol;
  return 0;
}
