#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int MAX = 3e5 + 5;
const long long MAX2 = 11;
const long long MOD = 1000000000;
const long long MOD2 = 1000005329;
const long long INF = 2e18;
const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1, 0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 2000;
long long n, m, k, x, y, a, b, ans, st;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> a >> b >> k;
  while (k--) {
    cin >> x >> y;
    st = 1e9;
    if (x < 0)
      st = (a - 1) / -x;
    else if (x > 0)
      st = (n - a) / x;
    if (y < 0)
      st = min(st, (b - 1) / -y);
    else if (y > 0)
      st = min(st, (m - b) / y);
    ans += st;
    a += st * x, b += st * y;
  }
  cout << ans << '\n';
  return 0;
}
