#include <bits/stdc++.h>
using namespace std;
const int INF = int(1e9);
long long n, m, T, x, y, dx, dy;
long long ans;
bool check(long long x, long long y) {
  if (0 < x && x <= n && 0 < y && y <= m)
    return 1;
  else
    return 0;
}
long long fun() {
  long long res = 0;
  for (long long i = 1000000011; i > 0; i /= 2)
    while (check(x + dx * i, y + dy * i)) {
      x += dx * i;
      y += dy * i;
      res += i;
    }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  cin >> x >> y;
  cin >> T;
  for (int i = 1; i <= T; ++i) {
    cin >> dx >> dy;
    ans += fun();
  }
  cout << ans;
  return 0;
}
