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 <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

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

ll gcd(ll *begin, ll *end) {
	ll res = *begin;
	while (begin != end) res = gcd(res, *begin), ++begin;
	return res;
}

ll lcm(ll *begin, ll *end) {
	ll res = *begin;
	while (begin != end) res = lcm(res, *begin), ++begin;
	return res;
}

int n;
ll d[10], v[10], ans[10];

int main() {
	while (cin >> n, n) {
		ll g;
		REP(i, n) {
			scanf("%lld %lld", d + i, v + i);
			g = gcd(d[i], v[i]);
			d[i] /= g; v[i] /= g;
		}
		
		g = gcd(d, d + n);
		REP(i, n) d[i] /= g;
		
		ll l = lcm(v, v + n);
		REP(i, n) ans[i] = d[i] * (l / v[i]);
		
		l = lcm(ans, ans + n);
		REP(i, n) ans[i] = l / ans[i];
		
		g = gcd(ans, ans + n);
		REP(i, n) ans[i] /= g;
		
		REP(i, n) cout << ans[i] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

long long gcd(long long a, long long b){ // Ååöñ
    if(a == 0 || b == 0)
        return 0;
    if(b > a)
        swap(a, b);
    long long tmp;
    while((tmp = a % b) != 0){
        a = b;
        b = tmp;
    }
    return b;
}

long long lcm(long long a, long long b){ // Å¬ö{
    return a / gcd(a, b) * b;
}

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<int> d(n), v(n);
        for(int i=0; i<n; ++i)
            cin >> d[i] >> v[i];

        vector<int> ret(n, 1);
        for(int i=1; i<n; ++i){
            int x1 = d[i] * v[i-1];
            int x2 = d[i-1] * v[i];
            int y = gcd(x1, x2);
            x1 /= y;
            x2 /= y;

            long long z = lcm(ret[i-1], x1);
            ret[i] = x2 * (z / x1);

            z /= ret[i-1];
            for(int j=0; j<i; ++j)
                ret[j] *= z;
        }

        for(int i=0; i<n; ++i)
            cout << ret[i] << endl;
    }
}

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

using namespace std;

long long int gcd(long long int);
long long int lcm(long long int, long long int);
pair<long long int, long long int> func(pair<long long int, long long int>, pair<long long int, long long int>);

int main(){
	int n;
	while (cin >> n, n) {
		vector<pair<long long int, long long int> > data;
		vector<long long int> p_lcm;
		for (int i = 0; i < n; i++) {
			int d, v; cin >> d >> v;
			data.push_back(make_pair((long long int)d, (long long int)v));
		}
		pair<long long int, long long int> cur = make_pair(data[0].first, data[0].second);
		for (int i = 1; i < data.size(); i++) {
			cur = func(cur, data[i]);
		}
		for (int i = 0; i < data.size(); i++) {
			cout << (cur.first * data[i].second) / (cur.second * data[i].first) << endl;	
		}
	}
	return 0;
}

long long int gcd(long long int a, long long int b){
	while (a != b) {
		if (a > b) {
			a = a - b;	
		} else {
			b = b - a;	
		}	
	}
	return a;
	/*
	if (a == b) return a;
	else {
		if (a > b) {
			return gcd(a - b, b);	
		} else {
			return gcd(b - a, a);	
		}	
	}
	*/
}

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

pair<long long int, long long int> func(pair<long long int, long long int> a, pair<long long int, long long int> b){
	long long int A = a.first * b.second, 
		   B = a.second * b.first;
	if (A == B) {
		if (a.second > b.second) {return make_pair(b.first, b.second);}
		else {return make_pair(a.first, a.second);}
	} else {
		if (a.second > b.second){
			return make_pair((lcm(A, B) / B) * b.first, b.second);	
		} else {
			return make_pair((lcm(A, B) / A) * a.first, a.second);	
		}
	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

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

int main()
{
	int n;
	while (cin >> n && n ){
		ll g, l;			// Ååöñ, Å¬ö{
		vector <P> d (n );
		rep (i, n ){
			cin >> d[i].first >> d[i].second;
		} // end rep
		rep (i, n ){
			g = __gcd(d[i].first, d[i].second );	
			d[i].first /= g;
			d[i].second /= g;
		} // end rep

		vector<P> pre;
		do{
			pre = d;
			g = d[0].first;
			for (int i = 1; i < n; i++ )
				g = __gcd (g, d[i].first );
			rep (i, n )
				d[i].first /= g;
		}while (pre != d );
		do{
			pre = d;
			g = d[0].second;
			for (int i = 1; i < n; i++ )
				g = __gcd (g, d[i].second );
			rep (i, n )
				d[i].second /= g;
		}while (pre != d );

		for (int i = 0; i < n; i++ ){
			if (d[i].second % d[i].first == 0 ){
				d[i].second /= d[i].first;
				continue;
			}else{
				ll nextm = d[i].first;
				for (int j = 0; j < n; j++ ){
					if (i != j )
						d[j].second *= nextm;
				} // end for
			} // end if
		} // end for
		do{
			pre = d;
			g = d[0].second;
			for (int i = 1; i < n; i++ )
				g = __gcd (g, d[i].second );
			rep (i, n )
				d[i].second /= g;
		}while (pre != d );

		rep (i, n ){
			cout << d[i].second << endl;
		} // end rep	

	} // end loop
		
	return 0;
}

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

using namespace std;

typedef long long ll;

template<class T>
inline T gcd(T a, T b) {
  return b > 0 ? gcd(b, a % b) : a;
}

template<class T>
inline T lcm(T a, T b) {
  return a*b/gcd(a, b);
}

int main() {
  int N;
  
  while(cin >> N && N) {
    vector<ll> d(N), v(N);
    
    for(int i=0; i<N; i++) {
      cin >> d[i] >> v[i];
      int const GCD = gcd(d[i], v[i]);
      d[i] /= GCD, v[i] /= GCD;
    }
    
    ll D = d[0], V = v[0];
    for(int i=1; i<N; i++) {
      D = lcm(D, d[i]);
      V = gcd(V, v[i]);
    }
    
    for(int i=0; i<N; i++) {
      cout << (v[i] * D) / (d[i] * V) << endl;
    }
  }
  
  return 0;
}