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>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
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(){
      ll n,d[10],v[10];
      while(cin>>n&&n){
            REP(i,n){
                  cin>>d[i]>>v[i];
                  ll a=gcd(d[i],v[i]);
                  v[i]/=a;d[i]/=a;
            }
            ll c=1;
            REP(i,n)c=lcm(c,d[i]);
            REP(i,n)v[i]*=(c/d[i]);
            ll ans=v[0];
            REP(i,n)ans=gcd(ans,v[i]);
            REP(i,n)cout<<v[i]/ans<<endl;
      }
}

C++: #include <iostream>
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
using namespace std;
#define ll long long
ll gcd(ll a, ll b) {
	if(b==0) return -1;
	if(a<b) swap(a,b);
	while(b) {
		ll t = a / b;
		swap(a-=t*b,b);
	}
	return a;
}
ll lcm(ll a, ll b) {
	ll c = gcd(a,b);
	return a * b / c;
}
int main(){
	int n;
	while(cin >> n, n) {
		ll d[10], v[10];
		rep(i,n) {
			cin >> d[i] >> v[i];
		}
		ll tr = d[0], td = v[0];
		rep2(i,1,n) {
			tr = lcm(tr * v[i], td * d[i]);
			td *= v[i];
			ll div = gcd(tr,td);
			tr /= div, td /= div;
		}
		rep(i,n) {
			cout << (tr*v[i]) /(d[i]*td) << endl;
		}
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

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

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> n, n) {
    for (int i = 0; i < n; i++) {
      cin >> d[i] >> v[i];
      ll g = gcd(d[i], v[i]);
    }
    ll A = 1;
    for (int i = 0; i < n; i++) {
      A = lcm(A, d[i]);
    }
    ll B = A / d[0] * v[0];
    for (int i = 0; i < n; i++) {
      B = gcd(B, A / d[i] * v[i]);
    }
    for (int i = 0; i < n; i++) {
      cout << A / d[i] * v[i] / B << endl;
    }
  }

  return 0;
}

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

using namespace std;

long int gcd(long int m,long int n){
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    while( m != n )
    {
        if ( m > n ) m = m - n;
        else         n = n - m;
    }
    return m;
}

long int lcm(long int m,long int n)
{
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    
    return ((m / gcd(m, n)) * n);
}

int main() {
    
    long int d,v,n;//,numerator[10];
    
    while (cin >> n) {
        if(n==0) break;
        vector<pair<long int,long int> > data;
        vector<pair<long int,long int> >::iterator it;
        for (int i=0; i<n; i++) {
            cin >> d >> v;
            pair<long int, long int> a(d,v);
            data.push_back(a);
        }
        
        long int v_1,result;
        it = data.begin();
        v_1 = it->second;
        it++;
        result = it->second;
        while(1){
            result = lcm(v_1, result);
            it++;
            if(it == data.end()) break;
            v_1 = it->second;
        }
        
        vector<long int> res;
        vector<long int>::iterator it_res;
        it = data.begin();
        while (it != data.end()) {
            v_1 = it->first * (result/it->second);
            res.push_back(v_1);
            it++;
        }
        it_res = res.begin();
        v_1 = *it_res;
        it_res++;
        result = *it_res;
        while(1){
            result = lcm(v_1, result);
            it_res++;
            if(it_res == res.end()) break;
            v_1 = *it_res;
        }
        
        it_res = res.begin();
        while (it_res != res.end()) {
            cout << result /(*it_res) << endl;
            it_res++;
        }
    }
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <utility>
#include <vector>
using namespace std;
#define debug(x) cout<<#x<<" = "<<x<<endl;

int n;
typedef pair<int,int> data;
typedef long long ll;
vector<data> datas;
ll gcd(const ll a,const ll b){
	return (b>0)? gcd(b, a%b) : a ;
}
ll lcm(const ll a,const ll b){
	return (a / gcd(a, b) * b);
}

void solve(){
  /* 通分 */
  //分母の最小公倍数
  ll lcd=1;//最小公分母

  for(int i=0;i<datas.size();i++){
    lcd=lcm(lcd,datas[i].second);
  }
  //debug(lcd);
  ll lcn=1;//最小公分子
  for(int i=0;i<datas.size();i++){
    lcn=lcm(lcn,datas[i].first*lcd/datas[i].second);
  }
  //debug(lcn);
  //debug(datas.size());
  for(int i=0;i<datas.size();i++){
    //cout<<lcn<<"*"<<datas[i].second<<"/"<<datas[i].first<<endl;
    cout<<lcn/lcd*datas[i].second/datas[i].first<<endl;
  }
}
int main(){
  while(cin >> n,n){
    datas.clear();
    for(int i=0;i<n;i++){
      ll d, v;
      cin >> d >> v;
      datas.push_back(make_pair(d,v));
    }
    solve();
  }
  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){
  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 vlc = v[0];
    for(int i = 1 ; i < n ; i++ ){
      vlc = lcm(vlc,v[i]);
    }

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

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