#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, x1, y1, dx, dy;
  int i, k;
  cin >> n >> m >> x1 >> y1 >> k;
  long long int ans = 0;
  for (i = 0; i < k; ++i) {
    cin >> dx >> dy;
    long long int t1 = 1e+9, t2 = 1e+9, t;
    if (dx < 0)
      t1 = (1 - x1) / dx;
    else if (dx > 0)
      t1 = (n - x1) / dx;
    if (dy < 0)
      t2 = (1 - y1) / dy;
    else if (dy > 0)
      t2 = (m - y1) / dy;
    t = min(t1, t2);
    x1 += t * dx;
    y1 += t * dy;
    ans += (long long int)t;
  }
  cout << ans;
  return 0;
}
