#include <bits/stdc++.h>
const int OO = (int)2e9;
const long long INF = (long long)4e18;
const double EPS = (double)1e-12;
using namespace std;
int n, m, q, rett;
long long res;
std::pair<int, int> pos, d, ret;
int main() {
  res = 0;
  scanf("%d %d %d %d %d", &n, &m, &pos.first, &pos.second, &q);
  while (q--) {
    ret = make_pair(OO, OO);
    scanf("%d %d", &d.first, &d.second);
    if (d.first < 0) ret.first = (1 - pos.first) / d.first;
    if (d.first > 0) ret.first = (n - pos.first) / d.first;
    if (d.second < 0) ret.second = (1 - pos.second) / d.second;
    if (d.second > 0) ret.second = (m - pos.second) / d.second;
    rett = min(ret.first, ret.second);
    pos = make_pair(pos.first + rett * d.first, pos.second + rett * d.second);
    res += (long long)rett;
  }
  cout << res << '\n';
  return 0;
}
