#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e6, mod = 1e9 + 7, inf = 1e10;
long long int a[N], dp[N];
int main() {
  long long int n, m, x, y, k, ans = 0, cnt;
  cin >> n >> m >> x >> y >> k;
  for (long long int i = 0; i < k; i++) {
    long long int a, b, dx = inf, dy = inf;
    cin >> a >> b;
    if (a < 0) dx = (x - 1) / abs(a);
    if (b < 0) dy = (y - 1) / abs(b);
    if (a > 0) dx = (n - x) / a;
    if (b > 0) dy = (m - y) / b;
    cnt = min(dx, dy);
    ans += cnt;
    x += (a * cnt);
    y += (b * cnt);
  }
  return cout << (ans), 0;
}
