#include <bits/stdc++.h>
int main() {
  int n, m, x, y;
  scanf("%d%d%d%d", &n, &m, &x, &y);
  long long cnt = 0;
  int k;
  scanf("%d", &k);
  while (k--) {
    int dx, dy;
    scanf("%d%d", &dx, &dy);
    int l = 0, r = 0x3f3f3f3f;
    while (l < r - 1) {
      int mid = (l + r) >> 1;
      long long ex = x + dx * 1LL * mid, ey = y + dy * 1LL * mid;
      if (ex >= 1 && ex <= n && ey >= 1 && ey <= m)
        l = mid;
      else
        r = mid;
    }
    x += dx * l, y += dy * l;
    cnt += l;
  }
  printf("%I64d\n", cnt);
  return 0;
}
