#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n = 0, m = 0, x = 0, y = 0, a = 0, b = 0, k = 0, r = 0, mi = 0;
  cin >> n >> m >> x >> y >> k;
  for (int i = 0; i < k; i++) {
    cin >> a >> b;
    mi = 1e18;
    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;
    r += mi;
  }
  cout << r;
  return 0;
}
