#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long N, M, K, x, y;
  pair<long long, long long> cur;
  queue<pair<long long, long long> > Q;
  long long count = 0;
  cin >> N >> M;
  cin >> cur.first >> cur.second;
  cin >> K;
  while (K--) {
    cin >> x >> y;
    Q.push(make_pair(x, y));
  }
  while (!Q.empty()) {
    pair<long long, long long> dir = Q.front();
    Q.pop();
    long long leastx = LONG_LONG_MAX;
    long long leasty = LONG_LONG_MAX;
    if (dir.first > 0ll) leastx = (N - cur.first) / (dir.first);
    if (dir.first < 0ll) leastx = (cur.first - 1ll) / (-dir.first);
    if (dir.second > 0ll) leasty = (M - cur.second) / (dir.second);
    if (dir.second < 0ll) leasty = (cur.second - 1ll) / (-dir.second);
    long long minn = min(leastx, leasty);
    count += minn;
    cur.first += minn * dir.first;
    cur.second += minn * dir.second;
  }
  cout << count << endl;
  return 0;
}
