#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, xc, yc, x, y, k, cnt = 0, xx, yy, a, b, j;
  cin >> n >> m >> xc >> yc >> k;
  while (k--) {
    cin >> x >> y;
    if (x > 0)
      a = (n - xc) / x;
    else if (x < 0)
      a = (1 - xc) / x;
    else if (x == 0)
      a = 1e9;
    if (y > 0)
      b = (m - yc) / y;
    else if (y < 0)
      b = (1 - yc) / y;
    else if (y == 0)
      b = 1e9;
    j = min(a, b);
    cnt += j;
    xc = xc + j * x;
    yc = yc + j * y;
  }
  cout << cnt << endl;
  return 0;
}
