#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 7;
const long long mod = 1e9 + 7;
long long n, m, k;
long long xc, yc;
long long x, y;
long long ans;
void solve() {
  cin >> n >> m;
  cin >> xc >> yc;
  cin >> k;
  cout << "\n";
  for (long long i = 1; i <= k; ++i) {
    cin >> x >> y;
    if (!x && !y) {
      continue;
    }
    long long a, b;
    if (x < 0) {
      a = xc - 1;
    } else
      a = n - xc;
    if (x) a /= x;
    if (y < 0)
      b = yc - 1;
    else
      b = m - yc;
    if (y) b /= y;
    if (!x) a = 1e9;
    if (!y) b = 1e9;
    a = min(abs(a), abs(b));
    xc += a * x;
    yc += a * y;
    ans += a;
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tt = 1;
  while (tt--) {
    solve();
  }
}
