#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n, m, Xc, Yc, k, nSteps = 0, dx, dy;
  cin >> n >> m >> Xc >> Yc >> k;
  for (long long i = 0; i < k; i++) {
    cin >> dx >> dy;
    long long stepX = INT_MAX, stepY = INT_MAX;
    if (dx > 0)
      stepX = (n - Xc) / dx;
    else if (dx < 0)
      stepX = (1 - Xc) / dx;
    if (dy > 0)
      stepY = (m - Yc) / dy;
    else if (dy < 0)
      stepY = (1 - Yc) / dy;
    long long newSteps = min(stepX, stepY);
    if (newSteps > 0 && newSteps != INT_MAX) {
      Xc += (newSteps * dx);
      Yc += (newSteps * dy);
      nSteps += newSteps;
    }
  }
  cout << nSteps;
  return 0;
}
