#include <bits/stdc++.h>
using namespace std;
int max(int a, int b) { return a > b ? a : b; }
int min(int a, int b) { return a < b ? a : b; }
int maxElement(int arr[], int n) {
  int maxi = arr[0];
  for (int i = 1; i < n; i++) {
    if (arr[i] > maxi) maxi = arr[i];
  }
  return maxi;
}
int minElement(int arr[], int n) {
  int mini = arr[0];
  for (int i = 1; i < n; i++) {
    if (arr[i] < mini) mini = arr[i];
  }
  return mini;
}
string trim(const string& str) {
  int first = str.find_first_not_of(' ');
  if (string::npos == first) {
    return str;
  }
  int last = str.find_last_not_of(' ');
  return str.substr(first, (last - first + 1));
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, m;
  cin >> n >> m;
  long long int x, y;
  cin >> x >> y;
  long long int k;
  cin >> k;
  long long int c = 0;
  for (int i = 0; i < k; i++) {
    long long int p, q;
    cin >> p >> q;
    long long int stepX = INT_MAX, stepY = INT_MAX;
    if (p > 0)
      stepX = (n - x) / p;
    else if (p < 0)
      stepX = (x - 1) / abs(p);
    if (q > 0)
      stepY = (m - y) / q;
    else if (q < 0)
      stepY = (y - 1) / abs(q);
    long long int min;
    if (stepX <= stepY) {
      min = stepX;
    } else {
      min = stepY;
    }
    c += min;
    x = x + (min * p);
    y = y + (min * q);
  }
  cout << c << '\n';
  cerr << "Time elapsed" << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
  return 0;
}
