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 <cmath>
#include <queue>
#include <vector>
#include <functional>

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

typedef pair<long long int, long long int> P;

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		long long int t = 1;
		vector<long long int> d(n);
		vector<long long int> v(n);
		for (int i = 0; i < n; i++) {
			cin >> d[i] >> v[i];
			t = lcm(max(v[i]*t, d[i]), min(v[i]*t, d[i])) / v[i];
			//cout << t << endl;
		}
		long long int a = v[0]*t/d[0];
		for (int i = 0; i < n; i++) {
			a = gcd(a, v[i]*t/d[i]);
		}
		for (int i = 0; i < n; i++) {
			cout <<(v[i]*t/d[i])/a << endl;
		}
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

const int N = 10000;

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

main(){
  lli n;
  lli d[N];
  lli v[N];
  lli ans[N];
  while(cin >> n && n){
    for(int i=0;i<n;i++){
      cin >> d[i] >> v[i];
    }
    for(int i=0;i<n;i++){
      int tmp = gcd(d[i], v[i]);
      d[i] /= tmp;
      v[i] /= tmp;
    }
    lli c = lcm(d[0], d[1]);
    for(int i=2;i<n;i++){
      c = lcm(c, d[i]);
    }
    for(int i=0;i<n;i++){
      ans[i] = c/d[i]*v[i];
    }
    c = gcd(ans[0], ans[1]);
    for(int i=2;i<n;i++){
      c = gcd(c, ans[i]);
    }
    for(int i=0;i<n;i++){
      cout << ans[i] / c << endl;
    }
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#define PB push_back
using namespace std;

int gcd(int a,int b){ return a%b==0 ? b : gcd(b,a%b);}

vector<long long int> ggg(vector<long long int> v){
    vector<long long int> ret;
    for(int i=0;i<v.size()-1;i++){
	ret.PB(gcd(v[i],v[i+1]));
    }
    return ret;
}

vector<long long int> lcm(vector<long long int> v){
    vector<long long int> ret;
    for(int i=0;i<v.size()-1;i++){
	ret.PB(v[i]*v[i+1]/gcd(v[i],v[i+1]));
    }
    return ret;
}
int main(){
    while(true){
        long long int p = 1;
        long long  int d[11];
        int n;
        cin >> n;
        vector<long long int> v(n);
	vector<long long int> lc;
        if(!n) break;
        for(int i=0;i<n;i++){
            cin >> d[i] >> v[i];
	    int t = gcd(d[i],v[i]);
	    d[i] = d[i]/t;
	    v[i] = v[i]/t;
	    lc.PB(d[i]);
        }
	while(lc.size()>1){
	    lc = lcm(lc);
	}
	vector<long long int> a = v;
	while(a.size()>1){
	    a = ggg(a);
	}
	vector<long long int> ans;
	bool flg = true;
	for(int i=0;i<n;i++){
	    ans.PB((v[i]/a[0])*(lc[0]/d[i]));
	}
	for(int i=0;i<n;i++){
	    cout << ans[i]<< endl;
	}
    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;

typedef unsigned long long int LL;
const int MAX_N = 10;

// aとbの最大公約数を返す(ユークリッドの互除法)
LL gcd(LL a, LL b){
    return (b == 0)? a : gcd( b , a%b ) ;
}

// aとbの最小公倍数を返す
LL lcm(LL a, LL b){
    return ( a / gcd(a,b) * b );
}

int main(){
	int n;
	while( cin >> n , n ){
		LL d[MAX_N], v[MAX_N];
		for(int i=0 ; i < n ; i++ ){
			cin >> d[i] >> v[i];
			LL a = gcd( d[i] , v[i] );
			d[i] = d[i] / a;
			v[i] = v[i] / a;
		}
		LL b = lcm( d[0] , d[1] );
		for(int i=2 ; i < n ; i++ ){
			b = lcm( b , d[i] );
		}
		LL f[MAX_N] = {0};
		for(int i=0 ; i < n ; i++ ){
			f[i] = v[i] * (b / d[i]);
		}
		LL c = gcd( f[0] , f[1] );
		for(int i=2 ; i < n ; i++ ){
			c = gcd( f[i] , c );
		}
		for(int i=0 ; i < n ; i++ ){
			cout << (f[i] / c) << endl;
		}
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ullong;
#define MAX 10
ullong gcd(ullong a, ullong b) {
	return (b == 0) ? a : gcd(b, a % b);
}
ullong lcm(ullong a, ullong b) {
	if (b > a)
		swap(a, b);
	return a / gcd(a, b) * b;
}
void compute(int n) {
	ullong d1, d2, v1, v2, G;
	pair<ullong, ullong> S[MAX];
	for (int i = 0; i < n; i++) {
		cin >> S[i].first >> S[i].second;
		G = gcd(S[i].first, S[i].second);
		S[i].first /= G;
		S[i].second /= G;
	}
	ullong l = lcm(S[0].first, S[1].first);
	for (int i = 2; i < n; i++)
		l = lcm(l, S[i].first);

	ullong A[MAX];
	for (int i = 0; i < n; i++)
		A[i] = S[i].second * (l / S[i].first);
	G = gcd(A[0], A[1]);
	for (int i = 2; i < n; i++)
		G = gcd(G, A[i]);
	for (int i = 0; i < n; i++)
		cout << A[i] / G << endl;
}
main() {
	int n;
	while( cin >> n && n ) compute(n);
}

C++: #include<cstdio>
#include<cstring>
using namespace std;

typedef long long ll;
int n;
ll d[10001],v[10001],k[10001],res[10001];

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

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

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<n;i++){
			scanf("%lld%lld",&d[i],&v[i]);
			ll G=gcd(d[i],v[i]);
			d[i]/=G;
			v[i]/=G;
		}
		ll dist=lcm(d[0],d[1]);
		for(int i=2;i<n;i++)dist=lcm(dist,d[i]);
		for(int i=0;i<n;i++)k[i]=dist/d[i]*v[i];
		ll t=gcd(k[0],k[1]);
		for(int i=2;i<n;i++)t=gcd(t,k[i]);
		for(int i=0;i<n;i++)res[i]=k[i]/t;
		for(int i=0;i<n;i++)printf("%lld\n",res[i]);
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <queue>
#include <vector>
#include <functional>

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

typedef pair<long long int, long long int> P;

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		vector< vector<long long int> > hyou(n, vector<long long int>(2));
		vector< vector<long long int> > hyou2(n, vector<long long int>(2));
		P pp;
		priority_queue< P, vector<P>, greater<P> > pq;
		for (int i = 0; i < n; i++) {
			cin >> pp.first >> pp.second;
			hyou[i][0] = pp.first;
			hyou[i][1] = pp.second;
			pq.push(pp);
		}
		for (int i = 0; i < n; i++) {
			P ppp = pq.top();
			pq.pop();
			hyou2[i][0] = ppp.first;
			hyou2[i][1] = ppp.second;
		}
		long long int p = hyou2[0][0];
		for (int i = 1; i < n; i++) {
			for (int j = 1; ; j++) {
				long double k = (long double)(p*j)/(long double)hyou2[0][1];
				long double b = (long double)hyou2[i][1]*k/(long double)hyou2[i][0];
				if (b-(long long int)b <= 1e-12) {
					p *= j;
					break;
				}
			}
		}
		long double kk = (long double)p/(long double)hyou2[0][1];
		for (int i = 0; i < n; i++) {
			cout << (long long int)(kk*hyou[i][1])/hyou[i][0] << endl;
		}
	}
	return 0;
}