#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
int gcd(int a, int b) {
  if (!b) return a;
  return gcd(b, a % b);
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
int n, m, cx, cy, k;
int main() {
  scanf("%d %d", &n, &m);
  scanf("%d %d", &cx, &cy);
  scanf("%d", &k);
  long long res = 0;
  while (k--) {
    int vx, vy;
    scanf("%d %d", &vx, &vy);
    long long l = 0, r = n + m, mid, steps = -1;
    while (l <= r) {
      mid = (l + r) / 2;
      long long nx = cx + vx * mid;
      long long ny = cy + vy * mid;
      if (nx > n || ny > m || nx <= 0 || ny <= 0)
        r = mid - 1;
      else
        steps = max(steps, mid), l = mid + 1;
    }
    res += steps;
    cx += vx * steps, cy += vy * steps;
  }
  printf("%lld\n", res);
  return 0;
}
