#include <bits/stdc++.h>
using namespace std;
int n, m, k, xs, ys;
int dx, dy;
int main() {
  long long p1, p2;
  cin >> n >> m;
  cin >> xs >> ys;
  cin >> k;
  long long ans = 0;
  for (int(i) = 0; (i) < (k); ++(i)) {
    cin >> dx >> dy;
    long long l = 0, r = 2 * 1000000000, mid;
    while (l + 1 < r) {
      mid = (l + r) / 2;
      p1 = xs + dx * mid;
      p2 = ys + dy * mid;
      if (p1 <= n && p1 > 0 && p2 <= m && p2 > 0)
        l = mid;
      else
        r = mid;
    }
    p1 = xs + dx * r;
    p2 = ys + dy * r;
    if (p1 <= n && p1 > 0 && p2 <= m && p2 > 0)
      mid = r;
    else
      mid = l;
    ans += mid;
    xs += dx * mid;
    ys += dy * mid;
  }
  cout << ans << endl;
}
