Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}
		d, v := make([]int, 0), make([]int, 0)
		for i := 0; i < n; i++ {
			scanner.Scan()
			buf := strings.Split(scanner.Text(), " ")
			a, _ := strconv.Atoi(buf[0])
			b, _ := strconv.Atoi(buf[1])
			g := _gcd(a, b)
			a /= g
			b /= g
			d = append(d, a)
			v = append(v, b)
		}
		g := lcm(n, d)
		for i := 0; i < n; i++ {
			d[i] = (g/d[i])*v[i]
		}
		g = gcd(n, d)
		for i := 0; i < n; i++ {
			fmt.Println(d[i]/g)
		}
	}
}

func _gcd(a, b int) int {
	for b != 0 {
		r := a % b
		a, b = b, r
	}
	return a
}

func gcd(n int, a []int) int {
	if n == 1 {
		return a[0]
	}
	g := _gcd(a[0], a[1])
	for i := 2; i < n; i++ {
		if g == 1 {
			break
		}
		g = _gcd(g, a[i])
	}
	return g
}

func lcm(n int, a []int) int {
	if n == 1 {
		return a[0]
	}
	g := _gcd(a[0], a[1])
	c := a[0] / g * a[1]
	for i := 2; i < n; i++ {
		g = _gcd(c, a[i])
		c = c / g * a[i]
	}
	return c
}

C++: #include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

ll gcd(ll a,ll b){
	if(b==0)
		return a;
	else
		return gcd(b,a%b);
}

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


void divs(ll &d,ll &v){
	for(ll i = 2; i <= min(d,v); i++){
		if(d%i==0&&v%i==0){
			d/=i;
			v/=i;
			i=1;
		}
	}
}

int main(){

	ll n;
	while(cin>>n&&n!=0){
		ll d,v;
		vector<ll> ds;
		vector<ll> vs;
		bool oo=false;
		for(ll i = 0; i < n; i++){
			cin>>d>>v;

			divs(d,v);


			ds.push_back(d);
			vs.push_back(v);
		}


		ll z=1;
		ll nums[11];
		ll allv=1;

		bool same=true;
		for(ll i = 1; i < n; i++){
			ll n1=ds[i-1]*vs[i];
			ll n2=ds[i]*vs[i-1];
			ll ret=lcm(n1,n2);
			ll r1=ret/n1;
			ll r2=ret/n2;
			if(ds[i-1]==ds[i]&&vs[i-1]==vs[i]){
				z=lcm(z,1);
				same=true;
			}
			else{
			//	if(vs[i-1]!=0)
					z=lcm(z,r1*ds[i-1]/vs[i-1]);
//				else
//					z=1;
				same=false;
			}
		}
		vector<ll> vll;
		ll m;
		if(!same){
			for(ll i = 0; i < n; i++){
				//if(ds[i]!=0){
					vll.push_back(z*vs[i]/ds[i]);
					if(i==0){
						m=z*vs[i]/ds[i];
					}
					else{
						m=gcd(m,z*vs[i]/ds[i]);
					}
			///	}
			//	else{
				//	vll.push_back(1);
				//	m=1;
			//	}
			}
			for(int i = 0; i < n; i++){
				if(m!=0)
					cout<<vll[i]/m<<endl;
				else
					cout<<1<<endl;
			}
		}
		else{
			for(int i = 0; i < n; i++){
				cout<<1<<endl;
			}
		}
	}

	return 0;
}

C++: #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;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
	long long n,q[10],v[10],a,b;
	long long x,y,c,d;
	while(true){
	cin>>n;
	if(n==0)break;
	cin>>a>>b;
	q[0]=a,v[0]=b;
	c=q[0],d=v[0];
	while(true){
		if(d>c){
			long long tmp=c;
			c=d;
			d=tmp;
		}
		if(d==c)break;
		c=c%d;
		if(c==0){c=d;break;}
	}
	q[0]/=c,v[0]/=c;
	a/=c,b/=c;
	for(int i=1;i<n;i++){
		cin>>q[i]>>v[i];
		c=q[i],d=v[i];
		while(true){
			if(d>c){
				long long tmp=c;
				c=d;
				d=tmp;
			}
			if(d==c)break;
			c=c%d;
			if(c==0){c=d;break;}
		}
		q[i]/=c,v[i]/=c;
		c=b,d=v[i];
		while(true){
			if(d>c){
				long long tmp=c;
				c=d;
				d=tmp;
			}
			if(d==c)break;
			c=c%d;
			if(c==0){c=d;break;}
		}
		x=c;
		c=a,d=q[i];
		while(true){
			if(d>c){
				long long tmp=c;
				c=d;
				d=tmp;
			}
			if(d==c)break;
			c=c%d;
			if(c==0){c=d;break;}
		}
		y=c;
		a=a*q[i]/y;
		b=x;
		c=a,d=b;
		while(true){
			if(d>c){
				long long tmp=c;
				c=d;
				d=tmp;
			}
			if(d==c)break;
			c=c%d;
			if(c==0){c=d;break;}
		}
		a/=c,b/=c;
	}
	for(int i=0;i<n;i++){
		long long ans=v[i]*a;
		ans/=q[i]*b;
		cout<<ans<<endl;
	}
	}
	return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;

#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

//?????§??¬?´???°
int gcd(int x, int y) { return y ? gcd(y, x%y) : x; }
//?????§??¬?´???° ?????°???
int gcd(const vector<int> &v) {
	int ret = v[0];
	rep(i, 1, v.size())ret = gcd(ret, v[i]);
	return ret;
}
//????°???¬?????°
int lcm(int x, int y) { return x*y / gcd(x, y); }
//????°???¬?????° ?????°???
int lcm(const vector<int> &v) {
	int ret = v[0];
	rep(i, 1, v.size())ret = lcm(ret, v[i]);
	return ret;
}

signed main() {
	for (int n; cin >> n&&n;) {
		vector<int> d(n), v(n); rep(i, 0, n) { cin >> d[i] >> v[i]; }
		int vg = gcd(v);
		vector<int> l(n);
		rep(i, 0, n) {
			l[i] = lcm(d[i], v[i] / vg) / (v[i] / vg);
		}
		int ll = lcm(l);
		rep(i, 0, n) {
			cout << ll*(v[i] / vg) / d[i] << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;
const int INF = 1<<29;
const double EPS = 1e-8;

int d[10],v[10];
int x[9],y[9];

int gcd(int x, int y){
    return y ? gcd(y, x%y): x;
}

int lca(int x, int y){
    long long int mul = (long long int)x*y;
    return mul/gcd(x,y);
}

int main(){
    while(1){
        int n;
        scanf("%d",&n);
        if(!n)break;

        for(int i=0;i<n;i++){
            scanf("%d%d",&d[i],&v[i]);
        }

        for(int i=0;i<n-1;i++){
            x[i] = d[i+1]*v[0];
            y[i] = d[0]*v[i+1];
            int g = gcd(x[i],y[i]);
            x[i] /= g;
            y[i] /= g;
            //cout << x[i] << " " << y[i] << endl;
        }

        if(n>2){
            int l = 1;
            for(int i=0;i<n-1;i++){
                l = lca(l, x[i]);
            }
            cout << l << endl;
            for(int i=0;i<n-1;i++){
                cout << l / x[i] * y[i] << endl;
            }
        }else{
            cout << x[0] << endl;
            cout << y[0] << endl;
        }

    }

    return 0;
}