#include <iostream>
#include <vector>
#include <utility>
using namespace std;

typedef long long ll;

ll gcd(ll n, ll m) {
	return n % m ? gcd(m, n % m) : m;
}
ll lcm(ll n, ll m) {
	return n * m / gcd(n, m);
}

int main() {
	int n;
	while(cin >> n, n) {
		vector<ll> d, v;
		for(int i = 0; i < n; i++) {
			ll a, b;
			cin >> a >> b;
			d.push_back(a);
			v.push_back(b);
		}

		vector<pair<ll,ll> > w;
		long long a = gcd(v[0]*d[1],v[1]*d[0]);
		w.push_back(pair<ll,ll>(d[1]*v[0] / a, d[0]*v[1] / a));
		for(int i = 2; i < n; i++) {
			a = gcd(d[i]*v[0], d[0]*v[i]);
			w.push_back(pair<ll,ll>(d[i]*v[0]/a, d[0]*v[i]/a));
		}

		ll l = 1;
		for(int i = 0; i < w.size(); i++) {
			l = lcm(l, w[i].first);
		}
		cout << l << endl;
		for(int i = 0; i < w.size(); i++) {
			cout << l / w[i].first * w[i].second << endl;
		}
	}
}