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<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

#ifdef __BORLANDC__
	typedef __int64 ll;
#else 
	typedef long long ll;
#endif


int n;
vector<int> d;
vector<int> s;
bool input(){
	cin>>n;
	if(n==0)return false;
	d=vector<int>(n);
	s=vector<int>(n);
	rep(i,n){
		cin>>d[i]>>s[i];
	}
	return true;
}

typedef pair<ll,ll> pll;


ll gcd(ll a, ll b){
	if(a<b)swap(a,b);
	
	while(1){
		ll c = a%b;
		if(c==0)return b;
		a = b;
		b = c;
	}
	return -1;
}
pll tubun(pll a){
	ll gc = gcd(a.first, a.second);
	a.first/=gc;
	a.second/=gc;
	return a;
}
ll lcm(ll a, ll b, ll c, ll d){
	pll tes1 = tubun(pll(a,b));
	pll tes2 = tubun(pll(c,d));
	
	a = tes1.first;  b = tes1.second;
	c = tes2.first;  d = tes2.second;
	
	
	ll bunbo = b*d;
	ll A = a*d;
	ll B = b*c;
	while(A==0 || B==0)printf("heeee");
	ll C = gcd(A,B);
	ll bunshi = A/C * B/C * C;
	
	return bunshi/bunbo;
}

const int N = 10;

vector<int> solve(){
	vector<int> ret;
	
	rep(i,n){
		pll hoge = tubun(pll(d[i],s[i]));
		d[i] = hoge.first;
		s[i] = hoge.second;
	}
	
	ll mygcd = gcd(s[0],s[1]);
	reps(i,2,n)mygcd = gcd(mygcd, s[2]);
	rep(i,n)s[i]/=mygcd;
	
	ll mylcm = lcm(d[0],s[0],d[1],s[1]);
	reps(i,2,n){
		mylcm = lcm(mylcm, 1, d[i], s[i]);
	}
	
	rep(i,n){
		ret.push_back((int)(mylcm/d[i]*s[i]));
	}
	
	return ret;
}

void c_solve(){
	vector<int> ans = solve();
	rep(i,ans.size())cout<<ans[i]<<endl;
}

int main(){
	while(input())c_solve();	
}

C++: #include<cstdio>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return (!b)?a:gcd(b,a%b);}
int main(){
int n,i,j;
ll d[10],v[10],t[10];
while(scanf("%d",&n) && n){
t[0]=1;
for(i=0;i<n;i++){
scanf("%lld%lld",&d[i],&v[i]);
if(i){
ll T=t[i]=t[i-1]*d[i-1]*v[i];
for(j=0;j<i;j++){
t[j] *= d[i]*v[i-1];
T=gcd(T,t[j]);}
for(j=0;j<=i;j++)t[j]/=T;}}
for(i=0;i<n;i++)printf("%lld\n",t[i]);}}

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{
				z=lcm(z,r1*ds[i-1]/vs[i-1]);
				same=false;
			}
		}
		//vector<ll> vll;
		//ll m;
		//if(!same){
		//	for(ll i = 0; i < n; i++){
		//		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]);
		//		}
		//	}
		//	for(int i = 0; i < n; i++){
		//		cout<<vll[i]/m<<endl;
		//	}
		//}
		//else{
		//	for(int i = 0; i < n; i++){
		//		cout<<1<<endl;
		//	}
		//}
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
typedef unsigned long long ull;

ull gcd(ull x, ull y)
{
  if (x < y) {
    swap(x, y);
  }
  ull r;
  while ((r = x % y) != 0) {
    x = y;
    y = r;
  }
  return y;
}

int main()
{
  int N;
  while (cin >> N && N != 0) {
    vector<pair<ull,ull> > v(N);
    ull g = (ull)-1;
    ull l = 1;
    for (int i = 0; i < N; i++) {
      ull d, w;
      cin >> d >> w;
      if (g == (ull)-1) {
        g = d;
      } else {
        g = gcd(g, d);
      }
      l *= d;
      v[i] = make_pair(d, w);
    }

    vector<ull> gs(N);
    gs[0] = v[0].second*l/g/v[0].first;
    ull h = gs[0];
    for (int i = 1; i < N; i++) {
      gs[i] = v[i].second*l/g/v[i].first;
      h = gcd(h, gs[i]);
    }
    for (int i = 0; i < N; i++) {
      cout << gs[i]/h << endl;
    }
  }
  return 0;
}

C++: #include<cstdio>
#include<algorithm>

using namespace std;

typedef	long long	ll;

ll gcd(ll a,ll b){
	for(;a;swap(a,b))	b%=a;
	return b;
}

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

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

		ll deno=d[0];
		for(int i=1;i<n;i++)	deno=lcm(deno,d[i]);
		ll nume[10];
		for(int i=0;i<n;i++)	nume[i]=v[i]*deno/d[i];
		ll g=nume[0];
		for(int i=1;i<n;i++)	g=gcd(g,nume[i]);
		for(int i=0;i<n;i++)	printf("%d\n",nume[i]/g);
	}

	return 0;
}

C++: #include <stdio.h>

#define MYSCAN scanf

int gcd(int a, int b);

int main(void){
	int n;
	int d1, v1;
	double d[11] = { 0 };
	int v[11] = { 0 };
	int kouyaku;
	long long ans[11];

	while (true){

		MYSCAN("%d", &n);
		if (n == 0){ break; }

		// テ・ツ?・テ・ツ環崚」ツつ津・ツ渉療」ツ?妥・ツ渉姪」ツつ?
		for (int i = 0; i < n; i++){
			MYSCAN("%lf%d", &d[i], &v[i]);
		}

		// テヲツ?堙ァツ崢エテ」ツ?ォテ、ツスツ陛ゥツ?アテ」ツ?凖」ツつ古」ツ?ーテ」ツ?ィテ」ツつ甘」ツ?づ」ツ?暗」ツ?堙・ツ青古ァツ敖?」ツ?凖」ツつ凝」ツ?ョテ」ツ?凝ゥツ?妥・ツシツオテ」ツつ?
		for (int i = 0; i < n; i++){
			ans[i] = v[i];
			for (int j = 0; j < n; j++){
				if (i != j){
					ans[i] *= d[j];
				}
			}
		}
		
		// テァツュツ氾」ツ?暗」ツ?ョテヲツ慊?・ツ、ツァテ・ツ?ャテァツエツ?ヲツ閉ーテ」ツつ津ヲツアツづ」ツつ?」ツ?ヲテ」ツ??」ツ?敕」ツつ古」ツ?ァテ・ツ?ィテ、ツスツ禿」ツつ津・ツ可イテ」ツつ?
		kouyaku = ans[0];
		for (int i = 1;	i < n; i++){
			kouyaku = gcd(ans[i], kouyaku);
		}

		for (int i = 0; i < n; i++){
			ans[i] /= kouyaku;
			printf("%lld\n", ans[i]);
		}

	}	
	return 0;
}



int gcd(int a, int b){
	int c;
	if (b == 0) return a;
	c = a % b;
	return gcd(b, c);
}