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;
	ll C = gcd(A,B);
	ll bunshi = A/C * B/C * C;
	
	while(bunbo>bunshi)printf("heee");
	return bunshi/bunbo;
}
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[i]);
	}
	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 <iostream>
#include <algorithm>
using namespace std;
typedef long long lli;

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

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

pair<lli,lli> irreducible(pair<lli,lli> p) {
  lli t = gcd(p.first,p.second);
  return make_pair(p.first/t,p.second/t);
}

pair<lli,lli> lcm(pair<lli,lli> a, pair<lli,lli> b) {
  a = irreducible(a);
  b = irreducible(b);
  lli t = lcm(a.second,b.second);
  return irreducible(make_pair(lcm(a.first*t/a.second,b.first*t/b.second),t));
}

const int MAX_N = 11;
int N;
lli D[MAX_N], V[MAX_N];

int main() {
  while(cin >> N && N) {
    for(int i = 0; i < N; ++i) cin >> D[i] >> V[i];
    pair<lli,lli> tmp = make_pair(D[0],V[0]);
    for(int i = 1; i < N; ++i) tmp = lcm(tmp,make_pair(D[i],V[i]));
    for(int i = 0; i < N; ++i) {
      cout << V[i]*tmp.first/D[i]/tmp.second << endl;
    }
  }
  return 0;
}

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

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;
		////for(ll i = 0; i < n; i++){
		////	allv*=vs[i];
		////}

		////for(ll i = 0; i < n; i++){
		////	nums[i]=ds[i]*allv/vs[i];
		////	z=lcm(z,nums[i]);
		////}
		////for(ll i = 0; i < n; i++){
		////	cout<<(z/nums[i])<<endl;
		////}
		//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 <cstring>
#include <algorithm>

using namespace std;

typedef long long ll;

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

int main()
{
    int n;

    while (cin >> n, n) {
        ll d[n], v[n], take[n];

        for (int i = 0; i < n; ++i) {
            cin >> d[i] >> v[i];
            take[i] = 3600 * d[i] / v[i];
        }

        ll time = take[0];
        for (int i = 1; i < n; ++i)
            time = lcm(time, take[i]);

        for (int i = 0; i < n; ++i)
            cout << v[i] * time / (d[i] * 3600) << endl;
    }

    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define int unsigned long long
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int MAX=10;
int n;
int d[MAX],v[MAX];

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

void solve(){
    int l=1;
    int latte=1;
    int malta=0;
    rep(i,n){
        cin>>d[i]>>v[i];
        int g=gcd(d[i],v[i]);
        d[i]/=g;v[i]/=g;
        l=lcm(l,v[i]);
    }
    rep(i,n){
        d[i]*=l/v[i];
        malta=gcd(malta,d[i]);
    }
    rep(i,n){
        d[i]/=malta;
        latte=lcm(latte,d[i]);
    }
    rep(i,n)cout<<latte/d[i]<<endl;
}
signed main(){
    cin.tie(0);ios_base::sync_with_stdio(0);
    while(cin>>n&&n)solve();
    return 0;
}