#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long modu(long long x, long long mod) { return x % mod; }
long long n, m, x, y, a, b, k, ans, mi;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> x >> y >> k;
  for (long long i = 0; i < k; i++) {
    cin >> a >> b;
    if (a == 0 && b == 0) continue;
    mi = INT_MAX;
    if (a > 0)
      mi = (n - x) / a;
    else if (a != 0)
      mi = -(x - 1) / a;
    if (b > 0)
      mi = min(mi, (m - y) / b);
    else if (b != 0)
      mi = min(mi, -(y - 1) / b);
    x += a * mi;
    y += b * mi;
    ans += mi;
  }
  cout << ans;
}
