#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x, y, k;
  long long rasp = 0;
  cin >> n >> m;
  cin >> x >> y;
  cin >> k;
  while (k--) {
    int a, b;
    cin >> a >> b;
    int dx = 1e9 + 7, dy = dx;
    if (a < 0) dx = (x - 1) / abs(a);
    if (b < 0) dy = (y - 1) / abs(b);
    if (a > 0) dx = (n - x) / a;
    if (b > 0) dy = (m - y) / b;
    int d = min(dx, dy);
    rasp += d;
    x = x + a * d;
    y = y + b * d;
  }
  cout << rasp;
}
