#include <bits/stdc++.h>
using namespace std;
const int N = 10000 + 11;
const int INF = 0x3f3f3f3f;
int n, m, s;
int dx, dy;
int sx, sy;
int main() {
  while (cin >> n >> m) {
    cin >> sx >> sy;
    cin >> s;
    long long ans = 0;
    for (int i = 0; i < s; ++i) {
      cin >> dx >> dy;
      int t = INF;
      if (dx) {
        if (dx > 0)
          t = min(t, (n - sx) / dx);
        else
          t = min(t, -(sx - 1) / dx);
      }
      if (dy) {
        if (dy > 0)
          t = min(t, (m - sy) / dy);
        else
          t = min(t, -(sy - 1) / dy);
      }
      ans += t;
      sx += t * dx;
      sy += t * dy;
    }
    cout << ans << endl;
  }
}
