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>

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(ll i = 2; i < min(d,v); 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;
		bool oo=false;
		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(ll 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++){
				if(m==0)
					cout<<1<<endl;
				else
					cout<<vll[i]/m<<endl;
			}
		}
		else{
			for(int i = 0; i < n; i++){
				cout<<1<<endl;
			}
		}
	}

	return 0;
}

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

using namespace std;

typedef unsigned long long BigInt;

BigInt lcm(BigInt a, BigInt b) {
  BigInt x = a;
  BigInt y = b;
  while (x != y) {
    if (x > y) {
      y += (x - y) / b * b;
      if (x > y) {
        y += b;
      }
    } else {
      x += (y - x) / a * a;
      if (x < y) {
        x += a;
      }
    }
  }
  return x;
}

BigInt gcd(BigInt a, BigInt b) {
  if (a < b) {
    swap(a, b);
  }
  while (b > 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}

int main() {
  int n;
  BigInt dh, vh;
  BigInt d[10], v[10];
  while (true) {
    cin >> n;
    if (n == 0) {
      return 0;
    }
    for (int i = 0; i < n; ++i) {
      cin >> d[i] >> v[i];
    }
    dh = d[0];
    vh = v[0];
    for (int i = 1; i < n; ++i) {
      BigInt y = lcm(v[i] * dh, vh * d[i]);
      BigInt kh = y / (v[i] * dh);
      BigInt z = gcd(dh * kh, vh);
      dh = dh * kh / z;
      vh /= z;
    }
    for (int i = 0; i < n; ++i) {
      cout << dh * v[i] / (d[i] * vh) << endl;
    }
  }
}

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

using namespace std;

long int gcd(long int a,long int b){
    long int	result = 1;
    long int	halfof_min_ab = (( a < b ) ? a : b ) / 2;
    long int	m = 2;
    while( m <= halfof_min_ab ){
        if( !( a % m ) && !( b % m )){
            result = m;
        }
        ++m;
    }
    return	result;
}

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

int main() {
    long int d,v,n;
    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()) {
            res.push_back(it->first * (result/it->second));
            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<bits/stdc++.h>
#define rep(i,n)for(ll i=0;i<n;i++)
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b) { if (!b)return a; return gcd(b, a%b); }
ll lcm(ll a, ll b) {
	ll g = gcd(max(a, b), min(a, b));
	return a / g*b / g*g;
}
ll d[20], v[20];
int main() {
	ll n;
	while (scanf("%lld", &n), n) {
		ll ans = 1;
		rep(i, n) {
			scanf("%lld%lld", &d[i], &v[i]);
			ans = lcm(ans, lcm(d[i], v[i]) / v[i]);
		}
		ll g = ans*v[0] / d[0];
		rep(i, n)g = gcd(g, ans*v[i] / d[i]);
		rep(i, n)printf("%lld\n", ans*v[i] / d[i] / g);
	}
}

C++: #include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

#define MAX 10
typedef long long ll;

ll d[MAX],v[MAX];

ll gcd(ll a,ll b){
  return __gcd(a,b);
}

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

int main(){
  int n;

  while(scanf("%d" ,&n) ,n){
    for(int i = 0 ; i < n ; i++){
      scanf("%lld %lld" ,&d[i] ,&v[i]);
      ll a = gcd(d[i],v[i]);
      d[i] /= a;
      v[i] /= a;
    }       
    
    ll T = d[0],V = v[0];
    for(int i = 1 ; i < n ; i++){
      T = lcm(T,d[i]);
      V = gcd(V,v[i]);
    }
    
    for(int i = 0 ; i < n ; i++){
      ll div = T / d[i];
      printf("%lld\n" ,div*v[i]/V);
    }
  }
  
  return 0;
}

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

using namespace std;

typedef long long int lli;

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

lli lcm(lli a, lli b)
{
  if(b > a) swap(a, b);
  return a/gcd(a, b)*b;
}

int main()
{
  lli t, n, d[10001], v[10001];
  while(cin>>n && n){
    for(int i = 0; i < n; ++i){
      cin >> d[i] >> v[i];
      t = gcd(d[i], v[i]);
      d[i] /= t;
      v[i] /= t;
    }

    t = lcm(d[0], d[1]);
    for(int i = 2; i < n; ++i)
      t = lcm(t, d[i]);

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

    t = gcd(v[0], v[1]);
    for(int i = 2; i < n; ++i)
      t = gcd(t, v[i]);

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

  return 0;
}