#include <bits/stdc++.h>   using namespace std;   long long int to_reach(long long int number, long long int moves,                          long long int target) {     if (target == 0) {       return (number / moves);     } else {       long long int res = (target - number) / moves;       return res;     }   }   int main() {     long long int n, m, xc, yc, dxi, dyi, step;     cin >> n >> m;     cin >> xc >> yc;     long long int k, count = 0;     cin >> k;     for (int i = 0; i < k; i++) {       cin >> dxi >> dyi;       long long int toReachX, toReachY;       if (dxi == 0)         toReachX = 10000000000;       else if (dxi > 0)         toReachX = to_reach(xc, dxi, n);       else         toReachX = to_reach(1 - xc, dxi, 0);       if (dyi == 0)         toReachY = 10000000000;       else if (dyi > 0)         toReachY = to_reach(yc, dyi, m);       else         toReachY = to_reach(1 - yc, dyi, 0);       long long int tomove = min(toReachX, toReachY);       xc = xc + dxi * tomove, yc = yc + dyi * tomove;       count += tomove;     }     cout << count << endl;     return 0;   }   