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>
using namespace std;

typedef long long ll;

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

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

int main(){
    int n;
    while(cin >> n, n){
        ll d[n], v[n], mother, child;
        cin >> d[0] >> v[0];
        ll g = gcd(d[0], v[0]);
        d[0] /= g, v[0] /= g;
        mother = v[0], child = d[0];
        for(int i = 1; i < n; i++){
            cin >> d[i] >> v[i];
            ll g = gcd(d[i], v[i]);
            d[i] /= g, v[i] /= g;
            mother = gcd(v[i], mother);
            child = lcm(d[i], child);
        }
        
        for(int i = 0; i < n; i++){
            cout << (child*v[i])/(d[i]*mother) << endl;
        }
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
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;}
main()
{
	int n;
	while(cin>>n,n)
	{
		int d[10],v[10];
		for(int i=0;i<n;i++)cin>>d[i]>>v[i];
		int a[10];
		for(int i=0;i<n;i++)a[i]=1;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(i==j)continue;
				int now=d[j]*v[i]/gcd(d[j]*v[i],d[i]*v[j]);
				a[i]=lcm(a[i],now);
			}
		}
		for(int i=0;i<n;i++)cout<<a[i]<<endl;
	}
}

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

typedef array<int,10000> Int;
typedef long long ll;

#define CR const &

Int gen(int x){
    Int res;
    res.fill(0);
    for (int i = 2; i <= x; i++){
        if (x%i == 0){
            int c = 0;
            while (x%i == 0)x /= i, c++;
            res[i] = c;
        }
    }
    return res;
}

ll rev(Int CR x){
    ll res = 1;
    for (int i = 0; i < 10000; ++i) {
        for (int j = 0; j < x[i]; ++j) {
            res *= i;
        }
    }
    return res;
}

Int mul(Int a, Int CR b){
    for (int i = 0; i < 10000; ++i) {
        a[i] += b[i];
    }
    return a;
}

Int div(Int a, Int CR b){
    for (int i = 0; i < 10000; ++i) {
        a[i] -= b[i];
    }
    return a;
}

Int gcd(Int a, Int CR b){
    for (int i = 0; i < 10000; ++i) {
        a[i] = min(a[i], b[i]);
    }
    return a;
}

Int lcm(Int a, Int CR b){
    for (int i = 0; i < 10000; ++i) {
        a[i] = max(a[i], b[i]);
    }
    return a;
}

Int d[20], v[20];

int main(int argc, char ** argv) {
    int n;
    while (cin >> n && n){
        Int l1;
        l1.fill(0);
        for (int i = 0; i < n; ++i) {
            ll dd, vv;
            cin >> dd >> vv;
            d[i] = gen(dd);
            v[i] = gen(vv);
            l1 = lcm(l1, v[i]);
        }
        Int l2;
        l2.fill(0);
        for (int i = 0; i < n; ++i) {
            l2 = lcm(l2, div(mul(d[i],l1) , v[i]));
        }
        for (int i = 0; i < n; ++i) {
            Int ans = div(mul(v[i], l2), mul(d[i], l1));
            cout << rev(ans) << endl;
        }
    }
}

C++: #include <cstdio>
#include <cmath>
#include <algorithm>
 
using namespace std;
 
#define MAX 10
typedef long long ll;
 
ll d[MAX], v[MAX];
 
ll gcd(ll a, ll b)
{
    return __gcd(a, b);
}
 
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
 
int main()
{
    int n;
 
    while (scanf("%d", &n), n) {
	for (int i = 0; i < n; i++) {
	    scanf("%lld %lld", &d[i], &v[i]);
	    ll a = gcd(d[i], v[i]);
	    d[i] /= a;
	    v[i] /= a;
	}       
     
	ll T = d[0], V = v[0];
	for (int i = 1; i < n; i++) {
	    T = lcm(T, d[i]);
	    V = gcd(V, v[i]);
	}
     
	for (int i = 0; i < n; i++) {
	    ll div = T / d[i];
	    printf("%lld\n", div*v[i]/V);
	}
    }
    return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

inline ll gcd(ll a, ll b) {
  return b > 0 ? gcd(b, a%b) : a;
}

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

int main() {
  
  int N;
  while(cin >> N && N) {
    vector<ll> vd(N), vv(N);
    rep(i, N) {
      cin >> vd[i] >> vv[i];
      int const GCD = gcd(vd[i], vv[i]);
      vd[i] /= GCD, vv[i] /= GCD;
    }
    
    ll D = vd[0], V = vv[0];
    REP(i,1,N) {
      D = lcm(D, vd[i]);
      V = gcd(V, vv[i]);
    }
    //cout << D << " " << V << endl;
    
    rep(i, N) cout << D*vv[i]/V/vd[i] << endl;
  }
  
  return 0;
}

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

long long d[10],v[10];

void compute(int n){
    for(int i = 2 ; i <= min(d[n],v[n]) ; i++){
        if(d[n]%i==0||v[n]%i==0){
            while(d[n]%i==0&&v[n]%i==0){
                d[n] /= i;
                v[n] /= i;
            }
        }
    }
}

int main(){
    int n;
    
    while(cin >>n,n){
        long long a,b;
        for(int i = 0 ; i < n ; i++){
            cin >> d[i] >> v[i];
            compute(i);
        }
        
        a = (d[0]*d[1])/__gcd(d[0],d[1]);
        b = __gcd(v[0],v[1]);
        
        for(int i = 2 ; i < n ; i++){
            a = (a*d[i])/__gcd(a,d[i]);
            b = __gcd(b,v[i]);
        }

        for(int i = 0 ; i < n ; i++){
            cout << a*v[i]/(b*d[i]) << endl;
        }
    }
    
    return 0;
}

C++: #include <iostream>
#include <cmath>
#include <queue>
#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);
}

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