#include <bits/stdc++.h>
int fx[] = {-1, +0, +1, +0, +1, +1, -1, -1, +0};
int fy[] = {+0, -1, +0, +1, +1, -1, +1, -1, +0};
int day[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
using namespace std;
long long n, m;
long long ini1, ini2;
long long a, b, cum = 0, step1 = 0, step2 = 0, dist1, dist2, fin1, fin2;
void checker() {
  step1 = step2 = 0;
  if (a > 0) {
    dist1 = n - ini1;
    step1 = dist1 / a;
  } else if (a < 0) {
    dist1 = ini1 - 1;
    step1 = dist1 / abs(a);
  } else if (a == 0)
    step1 = 1e18;
  if (b > 0) {
    dist2 = m - ini2;
    step2 = dist2 / b;
  } else if (b < 0) {
    dist2 = ini2 - 1;
    step2 = dist2 / abs(b);
  } else if (b == 0)
    step2 = 1e18;
  cum += min(step1, step2);
  long long x = min(step1, step2);
  if (x > 0) {
    if (a > 0)
      ini1 = a * x + ini1;
    else if (a < 0)
      ini1 = ini1 - x * abs(a);
    if (b > 0)
      ini2 = ini2 + x * b;
    else if (b < 0)
      ini2 = ini2 - abs(b) * x;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  cin >> ini1 >> ini2;
  int k;
  cin >> k;
  for (int i = (0); i < (k); i++) {
    cin >> a >> b;
    if (a == 0 && b == 0) continue;
    checker();
  }
  cout << cum;
  return 0;
}
