#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  long long x, y;
  cin >> x >> y;
  long long k;
  cin >> k;
  long long count = 0;
  while (k--) {
    int a, b;
    cin >> a >> b;
    long long ans = INT_MAX;
    if (a > 0) ans = ((n - x) / a);
    if (a < 0) ans = ((x - 1) / (-a));
    if (b > 0) ans = min(ans, (m - y) / b);
    if (b < 0) ans = min(ans, (y - 1) / (-b));
    count += ans;
    x = x + (a * ans);
    y = y + (b * ans);
  }
  cout << count << "\n";
}
