#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x, y, k, vx, vy, i;
  cin >> n >> m;
  cin >> x >> y;
  cin >> k;
  long long st = 0;
  int sx, sy, s, inf = 1e9 + 1;
  for (i = 0; i < k; ++i) {
    cin >> vx >> vy;
    if (vx < 0)
      sx = (x - 1) / (-1 * vx);
    else if (vx > 0)
      sx = (n - x) / vx;
    else
      sx = inf;
    if (vy < 0)
      sy = (y - 1) / (-1 * vy);
    else if (vy > 0)
      sy = (m - y) / vy;
    else
      sy = inf;
    s = min(sx, sy);
    st += s;
    x += s * vx;
    y += s * vy;
  }
  cout << st << "\n";
}
