#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, x, y, k, a, b, ans = 0;
  cin >> n >> m >> x >> y >> k;
  for (int i = 1; i <= k; ++i) {
    cin >> a >> b;
    long long calc = 1e9;
    if (a > 0) calc = (n - x) / a;
    if (a < 0) calc = (x - 1) / -a;
    if (b > 0) calc = min(calc, (m - y) / b);
    if (b < 0) calc = min(calc, (y - 1) / -b);
    ans += calc;
    x += calc * a;
    y += calc * b;
  }
  cout << ans << "\n";
}
