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<algorithm>
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 <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

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)
{
	if(a == 0 || b == 0) return 0;
	return ((a / gcd(a,b)*b));
}

int main()
{
	int n;
	while(cin >> n && n)
	{
		vector<pair<ll,ll> > v;
		
		rep(i,n)
		{
			ll a,b;
			cin >> a >> b;
			v.push_back(make_pair(a,b));
		}

		rep(i,n)
		{
			ll temp = gcd(v[i].first,v[i].second);
			v[i].first /= temp;
			v[i].second /= temp;
		}

		ll t,t2;
		rep(i,n)
		{
			if(i == 0)
			{
				t = v[i].first;
				t2 = v[i].second;
			}
			else
			{
				t = lcm(t,v[i].first);
				t2 = gcd(t2,v[i].second);
			}
		}

		rep(i,n)
		{
			ll ans = t * v[i].second;
			ans /= t2;
			ans /= v[i].first;
			cout << ans << endl;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
#define reps(i,n) for(int i = 0 ; i < (n) ; ++i )
#define rep(i,a,n) for(int i = (a) ; i < (n) ; ++i)
typedef long long ll;
int main(){
  int n;
  while(cin >> n , n){
    ll d[n] , v[n];
    reps(i,n) cin >> d[i] >> v[i];
    ll a = d[0];
    rep(i,1,n) a = d[i]*a / __gcd(d[i],a);
    ll b[n];
    reps(i,n) b[i] = v[i] * a / d[i];
    ll c = b[0];
    rep(i,1,n) c = __gcd(c,b[i]);
    reps(i,n) cout << b[i] / c << endl;;
  }
}

C++: #include<stdio.h>
typedef long long L;
L GCD(L a,L b){return b?GCD(b,a%b):a;}
L LCM(L a,L b){return a/GCD(a,b)*b;}
int main()
{
	int n,i;
	L v[10],v2[10],d[10],d2[10],gcd,lcm,t;
	while(scanf("%d",&n),n)
	{
		lcm=1;
		for(i=0;i<n;++i)
		{
			scanf("%lld%lld",d+i,v+i);
			gcd=GCD(v[i],d[i]);
			v[i]/=gcd;
			d[i]/=gcd;
			lcm=LCM(lcm,v[i]);
		}
		t=1;
		for(i=0;i<n;++i)
			t=LCM(t,lcm/v[i]*d[i]);
		for(i=0;i<n;++i)
			printf("%lld\n",t/d[i]*v[i]/lcm);
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;

const int INF = 1001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

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

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 main(){
    while(std::cin >> N, N){
        REP(i, N){
            std::cin >> d[i] >> v[i];
        }

        ll c = lcm(d[0]*v[1], d[1]*v[0]) / d[0] / v[1];
        FOR(i, 2, N){
            c = lcm(d[0]*v[i]*c, d[i]*v[0]) / d[0] / v[i];
        }

        REP(i, N){
            printf("%lld\n", c * d[0] * v[i] / v[0] / d[i]);
        }
    }
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

using namespace std;

long long int dist_origin[20], dist[20], laps[20];

long long int GCD(long long int a, long long int b){
	long long int dummy1, dummy2, dummy;
	dummy1 = max(a, b);
	dummy2 = min(a, b);
	while(true){
		dummy = dummy1 % dummy2;
		dummy1 = dummy2;
		dummy2 = dummy;
		if(dummy == 0){
			break;
		}
	}
	return dummy1;
}

int main(){
	
	int n;
	
	while(true){
		cin >> n;
		if(n == 0){
			break;
		}
		for(int i = 0; i < n; i++){
			cin >> dist_origin[i] >> laps[i];
			dist[i] = dist_origin[i];
		}
		for(int i = 0; i < n - 1; i++){
			long long int gcd = GCD(dist[i] * laps[i + 1], dist[i + 1] * laps[i]);
			long long int hoge = dist[i + 1];
			dist[i + 1] *= dist[i] * laps[i + 1] / gcd;
			for(int j = 0; j <= i; j++){
				dist[j] *= hoge * laps[i] / gcd;
			}
		}
		
		for(int i = 0; i < n; i++){
			long long int ans = dist[i] / dist_origin[i];
			cout << ans << endl;
		}
		
	}
	
	return 0;
}

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

using namespace std;

typedef unsigned 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 div(ll &d,ll &v){
	for(int i = 2; i < d; i++){
		if(d%i==0&&v%i==0){
			d/=i;
			v/=i;
			i--;
		}
	}
}

int main(){

	ll n;
	while(cin>>n&&n!=0){
		ll d,v;
		vector<ll> ds;
		vector<ll> vs;
		for(ll i = 0; i < n; i++){
			cin>>d>>v;

			div(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(int 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>

typedef unsigned long long int ll;

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

int main(){
	ll d[10], v[10], m = 1, c = 1;
	int n;
	while(std::cin >> n, n){
		m = c = 1;
		for(int i=0;i<n;i++){
			std::cin >> d[i] >> v[i];
			m *= v[i] / gcd(m, v[i]);
		}
		for(int i=0;i<n;i++){
			d[i] *= m / v[i];
			c *= d[i] / gcd(c, d[i]);
		}
		for(int i=0;i<n;i++){
			std::cout << c / d[i] << std::endl;
		}
	}
}