#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long long LL_INF = (long long)2e18 + 5;
inline void solve() {
  long long int n, m;
  cin >> n >> m;
  long int xc, yc, x, y;
  cin >> xc >> yc;
  long int k;
  cin >> k;
  int i;
  long long int res = 0, l, g, j;
  for (i = 0; i < k; i++) {
    cin >> x >> y;
    if (x > 0) {
      l = (n - xc) / x;
    } else if (x < 0) {
      l = (1 - xc) / x;
    } else
      l = 10000000000;
    if (y > 0)
      g = (m - yc) / y;
    else if (y < 0)
      g = (1 - yc) / y;
    else
      g = 10000000000;
    j = min(l, g);
    res += j;
    xc = xc + j * x;
    yc = yc + j * y;
  }
  cout << res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  solve();
}
