#include <bits/stdc++.h>
using namespace std;
const double PI = 3.141592654;
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
void fast() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL), cout.tie(NULL);
}
int main() {
  fast();
  int n, m, xc, yc, k;
  cin >> n >> m >> xc >> yc >> k;
  long long ans = 0;
  for (int(i) = 0; (i) < (long long)(k); (i)++) {
    int tox = INT_MAX, toy = INT_MAX, a, b;
    cin >> a >> b;
    if (a > 0)
      tox = (n - xc) / a;
    else if (a < 0)
      tox = (xc - 1) / abs(a);
    if (b > 0)
      toy = (m - yc) / b;
    else if (b < 0)
      toy = (yc - 1) / abs(b);
    ans += min(tox, toy);
    xc += min(tox, toy) * a;
    yc += min(tox, toy) * b;
  }
  cout << ans;
  return 0;
}
