#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n = 0, m = 0, sX = 0, sY = 0, k = 0, dX = 0, dY = 0, steps = 0,
                aY = 0, aX = 0, x = 0, y = 0, cur = 0;
  cin >> n >> m;
  cin >> sX >> sY;
  cin >> k;
  for (int i = 0; i < k; i++) {
    cin >> dX >> dY;
    y = x = -1;
    if (dX < 0) {
      aX = sX - 1;
    } else {
      aX = n - sX;
    }
    if (dX < 0)
      x = aX / (dX * -1);
    else if (dX > 0)
      x = aX / dX;
    if (dY < 0) {
      aY = sY - 1;
    } else {
      aY = m - sY;
    }
    if (dY < 0)
      y = aY / (dY * -1);
    else if (dY > 0)
      y = aY / dY;
    cur = steps;
    if (y < 0 && x > -1)
      steps += x;
    else if (x < 0 && y > -1)
      steps += y;
    else if (y < x && y > -1)
      steps += y;
    else if (x < y && x > -1)
      steps += x;
    else if (x == y && x > -1)
      steps += x;
    cur = steps - cur;
    sX += dX * cur;
    sY += dY * cur;
  }
  cout << steps;
  return 0;
}
