#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.1415926535897932384626433832795;
const long double eps = 1e-9;
long long int a[10001][2];
int main() {
  long long int n, m, x, y, k, i;
  cin >> n >> m >> x >> y >> k;
  for (i = 0; i < k; i++) {
    cin >> a[i][0] >> a[i][1];
  }
  long long int ans = 0, step = 0;
  long long int tempx, tempy;
  for (i = 0; i < k; i++) {
    if (a[i][0] > 0) tempx = abs(n - x) / (a[i][0]);
    if (a[i][1] > 0) tempy = abs(m - y) / (a[i][1]);
    if (a[i][0] < 0) tempx = (x - 1) / (abs(a[i][0]));
    if (a[i][1] < 0) tempy = (y - 1) / (abs(a[i][1]));
    if (a[i][0] == 0) tempx = 2000000000;
    if (a[i][1] == 0) tempy = 2000000000;
    step = min(tempx, tempy);
    ans += step;
    x = x + step * a[i][0];
    y = y + step * a[i][1];
  }
  cout << ans << endl;
  return 0;
}
