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>
#include <vector>
#include <queue>
#include <map>
#include <cstring>
#include <cstdio>
#define rep(i,n) for(int i = 0 ; i < n ; i++)
using namespace std;

typedef map<long long,int> U;

long long gcd(long long a,long long b){
	return b ? gcd(b,a%b) : a;
}

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

U factor(long long N){
	U p;
	for(int i = 2 ; i * i <= N ; i++){	
		while(N%i==0)p[i]++,N/=i;
	}
	if( N != 1 ) p[N]++;
	return p;
}
U gcd(U a,U b){
	U c;
	for( U::iterator it = a.begin() ; it != a.end() ; ++it){
		if( b.count(it->first) ) continue;
		c[it->first] = min(it->second,b[it->first]);
	}
	return c;
}
U lcm(U a,U b){
	U c;
	for( U::iterator it = a.begin() ; it != a.end() ; ++it){
		c[it->first] = max(c[it->first],it->second);
	}
	for( U::iterator it = b.begin() ; it != b.end() ; ++it){
		c[it->first] = max(c[it->first],it->second);
	}
	return c;
}
U mul(U a,U b){
	for( U::iterator it = a.begin() ; it != a.end() ; ++it){
		b[it->first] += it->second;
	}
	return b;
}
U div(U a,U b){
	for( U::iterator it = b.begin() ; it != b.end() ; ++it){
		a[it->first] -= it->second;
	}
	return a;
}
long long conv(U a){
	long long res = 1;
	for( U::iterator it = a.begin() ; it != a.end() ; ++it){
		for(int j = 0 ; j < it->second ; j++) res *= it->first;
	}
	return res;
}
int main(){
	ios_base::sync_with_stdio(false);
	int n;
	
	while(cin >> n && n){
		U  A[10],B[10] = {};
		U l;
		for(int i = 0 ; i < n ; i++){
			long long a_,b_;
			cin >> a_ >> b_;
			U a = factor(a_);
			U b = factor(b_);
			U g = gcd(a,b);
			a=div(a,g);
			b=div(b,g);
			l = lcm(l,b);
			A[i] = a;
			B[i] = b;
		}
		U L;
		for(int i = 0 ; i < n ; i++){
			U a = div(mul(A[i],l),B[i]);
			//cout << a << endl;
			B[i] = l;
			A[i] = a;
			L = lcm(a,L);
		}
		for(int i = 0 ; i < n ; i++){
			cout << conv(div(L,A[i])) << endl;
		}
		
	}
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<30;

typedef long long Int;

Int gcd(Int a, Int b) {
  return b==0 ? a : gcd(b, a%b);
}
Int lcm(Int a, Int b) {
  // printf("%lld,%lld  %lld\n",a,b,gcd(a,b));
  return a / gcd(a,b) * b;
}
Int gcd(vector<Int> v) {
  Int res = 0;
  REP(i,v.size()) {
    if (!i) res = v[0];
    else res = gcd(res,v[i]);
  }
  return res;
}
Int lcm(vector<Int> v) {
  Int res = 1;
  FOR(it,v)
    res = lcm(res, *it);
  return res;
}

int main() {
  int n;
  while(cin >> n, n) {
    vector<Int> d(n), v(n);
    REP(i,n)
      cin >> d[i] >> v[i];
    Int l = lcm(d);
    // cout << " "<<l << endl;
    vector<Int> ans;
    REP(i,n)
      ans.push_back(l / d[i] * v[i]);
    Int g = gcd(ans);
    REP(i,n)
      cout << ans[i] / g << endl;
  }
}

C++: #include <bits/stdc++.h>

using namespace std;

typedef long long lint;

lint gcd(lint x, lint y){ return __gcd(x, y); }
lint lcm(lint x, lint y){ return x / gcd(x, y) * y; }

int main()
{
	int n;
	while (cin >> n, n){
		vector<pair<lint, lint> > ss;
		lint l = 1;
		for (int i = 0; i < n; i++){
			lint d, v;
			cin >> d >> v;
			lint g = gcd(d, v);
			l = lcm(l, d / g);
			ss.push_back(make_pair(d, v));
		}
		lint g = l * ss[0].second / ss[0].first;
		for (int i = 1; i < n; i++){
			g = gcd(l * ss[i].second / ss[i].first, g);
		}
		for (int i = 0; i < n; i++){
			cout << l * ss[i].second / ss[i].first / g << endl;
		}
	}
	return (0);
}

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

using namespace std;
typedef long long int ll;

ll gcd(ll a,ll b){
  if(a < b)swap(a,b);
  while(1){
    ll t = a%b;
    a = b;
    b = t;
    if(b == 0)return a;
  }
}

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

int main(){
  ll n;
  while(cin >> n , n){

    ll d[10],v[10];
    for(ll i = 0 ; i < n ; i++ ){
      cin >> d[i] >> v[i];
      ll cd = gcd(d[i],v[i]);
      d[i]/=cd;
      v[i]/=cd;
    }

    ll dlc = d[0];
    for(int i = 1 ; i < n ; i++ ){
      dlc = lcm(dlc,d[i]);
      }
    for(int i = 1 ; i < n ; i++ ){
      v[i] = v[i]*(dlc/d[i]);
    }
    ll vlc = v[0];
    for(int i = 1 ; i < n ; i++ ){
      vlc = gcd(vlc,v[i]);
    }
    for(int i = 0 ; i < n ; i++ )cout << v[i]/vlc << endl;

  }
  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 ), v(n );

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

using namespace std;

unsigned long gcm(unsigned long int x, unsigned long int y) {
	unsigned long int z;
	while (y) {
		z = y;
		y = x % y;
		x = z;
	}
	return x;
}

int main () {
    unsigned long int n;
    while (cin >> n, n) {
		unsigned long int d[11], v[11], z;
		for (int i = 0; i < n; ++i) {
			cin >> d[i] >> v[i];
			z = gcm(d[i], v[i]);
			d[i] /= z, v[i] /= z;
		}
		v[10] = v[0];
		for (int i = 1; i < n; ++i)
			v[10] *= v[i] / gcm(v[10], v[i]);

		for (int i = 0; i < n; ++i)
			d[i] *= v[10] / v[i];

		d[10] = d[0];
		for (int i = 1; i < n; ++i)
			d[10] *= d[i] / gcm(d[10], d[i]);

		for (int i = 0; i < n; ++i)
			cout << (d[10] / d[i]) << endl;

		cout << d[10] << endl;
    }
}

C++: #include <cstdio>
#include <utility>
using namespace std;
typedef pair<int,int> P;
int d[10],v[10];
P p[9];
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;
}
int main() {
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		scanf("%d %d",&d[i],&v[i]);
	}
	for(int i=0;i+1<n;i++) {
		int x=v[i]*d[i+1],y=d[i]*v[i+1],g=gcd(x,y);
		p[i]=P(x/g,y/g);
	}
	int m=n-1;
	for(int i=0;i+1<m;i++) {
		int l=lcm(p[i].second,p[i+1].first);
		p[i+1].second*=(l/p[i+1].first);
		for(int j=0;j<=i;j++)
			p[j].first*=(l/p[i].second);
		p[i].second=p[i+1].first=l;
	}
	for(int i=0;i<m;i++) {
		printf("%d\n",p[i].first);
	}
	printf("%d\n",p[m-1].second);
}