#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int n, m, posx, posy, k, a, b;
  long long movx, movy;
  long long ans = 0;
  cin >> n >> m >> posx >> posy >> k;
  for (int i = 0; i < k; i++) {
    cin >> a >> b;
    if (a > 0)
      movx = n - posx;
    else if (a < 0)
      movx = posx - 1;
    else
      movx = INT_MAX;
    if (a != 0) movx /= abs(a);
    if (b > 0)
      movy = m - posy;
    else if (b < 0)
      movy = posy - 1;
    else
      movy = INT_MAX;
    if (b != 0) movy /= abs(b);
    posx += a * min(movy, movx);
    posy += b * min(movy, movx);
    ans += min(movy, movx);
  }
  cout << ans;
  return 0;
}
