#include <bits/stdc++.h>
using namespace std;
long long n, m, x, y, k;
int main() {
  long long a, b;
  long long ans = 0, xx, yy;
  scanf("%I64d %I64d %I64d %I64d %I64d", &n, &m, &x, &y, &k);
  while (k--) {
    scanf("%I64d %I64d", &a, &b);
    xx = 1 << 30;
    yy = 1 << 30;
    if (a > 0)
      xx = (n - x) / a;
    else if (a < 0)
      xx = (1 - x) / a;
    if (b > 0)
      yy = (m - y) / b;
    else if (b < 0)
      yy = (1 - y) / b;
    ans += min(xx, yy);
    x += min(xx, yy) * a;
    y += min(xx, yy) * b;
  }
  printf("%I64d\n", ans);
}
