#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>


using namespace std;



int main() {
	int n;
	cin >> n;
	long long minx = 1, miny = 1;
	for (int i = 0; i < n; i++) {
		int t, a;
		cin >> t >> a;
		if (t == 0) break;
		while (true) {
			if ((minx % t) * (a % t) % t == 0 && (minx / t) * a >= miny) {
				miny = (minx / t) * a;
				break;
			};
			minx++;
		}
	}
	cout << minx + miny << endl;




}


