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 unsigned long long int lli;
struct student{
  int d, v;
};
vector<student> vs;

lli __gcd(lli a, lli b){
  if(b == 0)return a;
  return __gcd(b, a%b);
}
lli __lcm(lli a, lli b){
  return a/__gcd(a, b)*b;
}
int main(int argc, char *argv[]){
  int n;
  while(std::cin >> n, n){
    vs.clear();
    for (int i = 0; i < n; i++) {
      student s;
      std::cin >> s.d >> s.v;
      vs.push_back(s);
    }
    lli lcm = 1;
    for (int i = 0; i < n; i++) {
      lcm = __lcm(lcm, vs[i].v);
    }
    vector<lli> ans(n);
    for (int i = 0; i < n; i++) {
      ans[i] = lcm/vs[i].v*vs[i].d;
    }
    lli gcd = ans[0];
    for (int i = 0; i < n; i++) {
      gcd = __gcd(gcd, ans[i]);
    }
    for (int i = 0; i < n; i++) {
      ans[i] /= gcd;
    }
    lcm = 1;
    for (int i = 0; i < n; i++) {
      lcm = __lcm(lcm, ans[i]);
    }
    for (int i = 0; i < n; i++) {
      std::cout << lcm/ans[i] << std::endl;
    }
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
ll gcd(ll a,ll b){
      if(b==0)return a;
      return gcd(b,a%b);
}
ll lcm(ll a,ll b){
      return a/gcd(a,b)*b;
}
int main(){
      ll n,d[10],v[10];
      while(cin>>n&&n){
            ll c;
            REP(i,n){
                  cin>>d[i]>>v[i];
                  if(i==0)c=v[i];
                  else c=lcm(v[i],c);
            }
            REP(i,n)d[i]=d[i]*c/v[i];
            ll ans=0;
            REP(i,n){
                  if(i==0)ans=d[i];
                  else ans=lcm(ans,d[i]);
            }
            REP(i,n){
                  cout<<ans/d[i]<<endl;
            }
      }
}

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


typedef pair<ll,ll> pll;

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;
}


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;
	}
}

void tubun(ll* a, ll* b){
	ll c = gcd(*a, *b);
	*a /= c;
	*b /= c;
}

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


pll lcmexp(ll a, ll b, ll c, ll d)
{
	tubun(&a, &b); tubun(&c, &d);
	
	ll bunbo = b*d;
	ll A = a*d;
	ll B = b*c;
	
	//ll gcA = gcd(A, bunbo); A/=gcA; bunbo/=gcA;
	//ll gcB = gcd(B, bunbo); B/=gcB; bunbo/=gcB;
	
	ll C = gcd(A,B);
	ll bunshi = A/C*B/C*C;
	
	//cout<<"bunbo="<<bunbo<<" bunshi="<<bunshi<<"  A="<<A<<"  B="<<B<<endl;
	tubun(&bunbo, &bunshi);
	
	return pll(bunshi, bunbo);
}



vector<int> solve(){
	vector<int> ret;
	
	pll lcme = lcmexp(d[0], s[0], d[1], s[1]);
	reps(i,2,n){
		lcme = lcmexp(lcme.first, lcme.second, d[i], s[i]);
	}
	
	//cout<<"aaa"<<lcme.first<<" "<<lcme.second<<endl;
	
	rep(i,n){
		ret.push_back(lcme.first * s[i] / d[i] / lcme.second);
	}
	
	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 <iostream>
#include <algorithm>

using namespace std;
typedef long long int ll;

ll gcd(ll a,ll b){
  if(a < b)swap(a,b);
  while(1){
    ll t = a%b;
    a = b;
    b = t;
    if(b == 0)return a;
  }
}

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

int main(){
  ll n;
  while(cin >> n , n){

    ll d[10],v[10];
    for(ll i = 0 ; i < n ; i++ ){
      cin >> d[i] >> v[i];
      ll cd = gcd(d[i],v[i]);
      d[i]/=cd;
      v[i]/=cd;
    }

    ll dlc = d[0],vlc = v[0];
    for(int i = 1 ; i < n ; i++ ){
      dlc = lcm(dlc,d[i]);
      vlc = lcm(vlc,v[i]);
    }
    d[0] = d[0]*(vlc/v[0]);
    ll dgc  = d[0];
    for(int i = 1 ; i < n ; i++ ){
      d[i] = d[i]*(vlc/v[i]);
      dgc = gcd(dgc,d[i]);
    }
    for(int i = 0 ; i < n ; i++ )d[i]/=dgc;
    ll ddlc = d[0];
    for(int i = 1 ; i < n ; i++ ){
      ddlc = lcm(ddlc,d[i]);
    }

    for(int i = 0 ; i < n ; i++ )cout << ddlc/d[i] << endl;

  }
  return 0;
}

C++: #include <iostream>
#define int unsigned long long
using namespace std;

int gcd(int a,int b){
	if(a < b) swap(a,b);
	while(b){
		a %= b;
		swap(a,b);
	}
	return a;
}

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

signed main(){
	int n;
	while(cin >> n,n){
		int d[10],v[10],ld = 1,lv = 1;
		for(int i = 0;i < n;i++) {
			cin >> d[i] >> v[i];
			ld = lcm(ld,d[i]);
			lv = lcm(lv,v[i]);
		}
		for(int i = 0;i < n;i++) {
			if(!i) lv = ld / d[i] * v[i];
			else lv = gcd(lv,ld / d[i] * v[i]);
		}
		for(int i = 0;i < n;i++) cout << ld / d[i] * v[i] / lv << endl;
	}
	return 0;
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

long long int gcd(long long int l, long long int r) {
	assert(l > 0 && r > 0);
	if (l > r)return gcd(r, l);
	else {
		const long long int num = r%l;
		if (num) {
			return gcd(l, num);
		}
		else {
			return l;
		}
	}
}
long long int lca(long long int l, long long int r) {
	return l / gcd(l, r)*r;
}

int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		if (!N)break;
		vector<long long int>ds(N), vs(N);
		for (int i = 0; i < N; ++i) {
			long long int d, v; cin >> d >> v;
			long long int agcd(gcd(d, v));
			d /= agcd; v /= agcd;
			ds[i] = d; vs[i] = v;
		}
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				if (i == j)continue;
				ds[i] *= vs[j];
			}
		}
		long long int alca = 1;
		for (int i = 0; i < N; ++i) {
			alca = lca(alca, ds[i]);
		}
		for (int i = 0; i < N; ++i) {
			cout << alca / ds[i] << endl;
		}
	}
	
	return 0;
}