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

using namespace std;

long long int gcd(long long int a, long long int b) {
	if (b == 0) {
		return a;
	} else {
		return gcd(max(b, a%b), min(b, a%b));
	}
}

long long int lcm(long long int a, long long int b) {
	return a * b / gcd(a, b);
}

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		vector< vector<long long int> > hyou(n, vector<long long int>(2));
		for (int i = 0; i < n; i++) {
			cin >> hyou[i][0] >> hyou[i][1];
		}
		long long int p = hyou[0][0];
		for (int i = 1; i < n; i++) {
			for (int j = 1; ; j++) {
				long double k = (long double)(p*j)/(long double)hyou[0][1];
				long double b = (long double)hyou[i][1]*k/(long double)hyou[i][0];
				if (b-(long long int)b <= 1e-12) {
					p *= j;
					break;
				}
			}
		}
		long double kk = (long double)p/(long double)hyou[0][1];
		for (int i = 0; i < n; i++) {
			cout << (long long int)(kk*hyou[i][1])/hyou[i][0] << endl;
		}
	}
	return 0;
}