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>

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

using namespace std;

typedef long long ll;

int n;

void make_irre (vector <ll> & a )
{
	ll g;			// Ååöñ
	vector <ll> pre;
	do{
		pre = a;
		g = a[0];
		for (int i = 1; i < n; i++ )
			g = __gcd (g, a[i] );
		rep (i, n )
			a[i] /= g;
	}while (pre != a );
}

int main()
{
	while (cin >> n && n ){
		vector <ll> d (n, 0LL ), v(n, 0LL );

		rep (i, n )
			cin >> d[i] >> v[i];

		// ùñªÌ
		rep (i, n ){
			ll g = __gcd(d[i], v[i] );	
			v[i] /= g;
			d[i] /= g;
		} // end rep
		// ¬x¯mÌùñ»(?)
		make_irre (v );

		// £¯mÌùñ»(?)
		make_irre (d );

		// ®ä»
		rep (i, n ){
			if (v[i] % d[i] == 0 ){
				v[i] /= d[i];
			}else{
				ll m = d[i];
				rep (j, n )
					if (i != j )
						v[j] *= m;
			} // end if
		} // end rep
		make_irre (v );

		rep (i, n )
			cout << v[i] << endl;
	} // end loop
		
	return 0;
}

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;
int n;

void make_irre (vector <ll> & a )
{
	ll g;			// Ååöñ
	vector <ll> pre;
	do{
		pre = a;
		g = a[0];
		for (int i = 1; i < n; i++ )
			g = __gcd (g, a[i] );
		rep (i, n )
			a[i] /= g;
	}while (pre != a );
}

int main()
{
	while (cin >> n && n ){
		vector <ll> d (n, 0LL ), v(n, 0LL );

		rep (i, n )
			cin >> d[i] >> v[i];
		// ùñªÌ
		rep (i, n ){
			ll g = __gcd(d[i], v[i] );	
			v[i] /= g;
			d[i] /= g;
		} // end rep
		// ¬x¯mÌùñ»(?)
		make_irre (v );
		// £¯mÌùñ»(?)
		make_irre (d );
		// ®ä»
		rep (i, n ){
			if (v[i] % d[i] == 0 ){
				v[i] /= d[i];
			}else{
				ll m = d[i];
				rep (j, n )
					if (i != j )
						v[j] *= m;
			} // end if
		} // end rep
		make_irre (v );

		rep (i, n )
			cout << v[i] << endl;
	} // end loop
		
	return 0;
}

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

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

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

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

int main()
{
	int  is_prime[1000000];
	is_prime[0] = is_prime[1] = 0;
	for(int i=2; i<1000000; i++)
		is_prime[i] = 1;

	for(int i=2; i*i<1000000; i++){
		if(is_prime[i]){
			for(int j=i*i; j<1000000; j+=i)
				is_prime[j] = -1;
		}
	}
	
	int n;
		
	while(true){
		cin >> n;
		if(n==0)
			break;

		for(int i=n; i>2; i--){
			if(is_prime[i] == 1 && is_prime[i-2] == 1 && is_prime[i-6] == 1 && is_prime[i-8] == 1){
				if(is_prime[i] == is_prime[i-2] && is_prime[i] == is_prime[i-6] && is_prime[i] == is_prime[i-8]){
					cout << i << endl;
					break;
				}
			}
		}
		
	}
	return 0;
}

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

typedef map<int, int> mii;
typedef long long ll;

#define CR const &

mii gen(int x){
    map<int, int> res;
    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(mii CR x){
    ll res = 1;
    for (auto & p : x){
        ll a, b;
        tie(a, b) = p;
        assert(b >= 0);
        for (int i = 0; i < b; ++i) {
            res *= a;
        }
    }
    return res;
}

mii mul(mii a, mii CR b){
    for (auto & p : b){
        a[p.first] += p.second;
    }
    return a;
}

mii div(mii a, mii CR b){
    for (auto & p : b){
        a[p.first] -= p.second;
    }
    return a;
}

mii gcd(mii a, mii CR b){
    for (auto & p : b){
        a[p.first] = min(a[p.first], p.second);
    }
    return a;
}

mii lcm(mii a, mii CR b){
    for (auto & p : b){
        a[p.first] = max(a[p.first], p.second);
    }
    return a;
}

int main(int argc, char ** argv) {
    int n;
    while (cin >> n && n){
        mii d[20], v[20];
        mii l1;
        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]);
        }
        mii l2;
        for (int i = 0; i < n; ++i) {
            l2 = lcm(l2, div(mul(d[i],l1) , v[i]));
        }
        for (int i = 0; i < n; ++i) {
            mii ans = div(mul(v[i], l2), mul(d[i], l1));
            cout << rev(ans) << endl;
        }
    }
}

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

typedef long long int ll;

ll lcm(ll a,ll b){
    if(a<b)swap(a, b);
    ll gcd=a%b;
    ll x=a*b;
    while (gcd!=0) {
        a=b;
        b=gcd;
        gcd=a%b;
    }
    return x/b;
}

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

int main(){
    int n;
    while (1) {
        cin>>n;
        if(n==0)break;
        vector<pair<ll, ll> >dv(n);
        int d,v;
        for (int i=0; i<n; i++) {
            cin>>d>>v;
            ll r=gcd(d,v);
            d/=r;
            v/=r;
            dv[i]=make_pair(d, v);
        }
        ll l=dv[0].first;
        for (int i=0; i<n-1; i++) {
            l=lcm(l, dv[i+1].first);
        }
        ll a[n];
        for (int i=0; i<n; i++) {
            a[i]=l*dv[i].second/dv[i].first;
        }
        ll 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;
    }
    return 0;
}