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 <map>

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<vector>
#include<algorithm>
using namespace std;
typedef unsigned long long int lli;
struct student{
  int d, v;
};
vector<student> vs;

lli __gcd(lli a, lli b){
  if(b == 0)return a;
  return __gcd(b, a%b);
}
lli __lcm(lli a, lli b){
  return a/__gcd(a, b)*b;
}
int main(int argc, char *argv[]){
  int n;
  while(std::cin >> n, n){
    vs.clear();
    for (int i = 0; i < n; i++) {
      student s;
      std::cin >> s.d >> s.v;
      lli g = __gcd(s.d, s.v);
      s.v /= g;
      s.d /= g;
      vs.push_back(s);
    }
    lli lcm = 1;
    for (int i = 0; i < n; i++) {
      lcm = __lcm(lcm, vs[i].v);
    }
    vector<lli> ans(n);
    for (int i = 0; i < n; i++) {
      ans[i] = lcm/vs[i].v*vs[i].d;
    }
    lli gcd = ans[0];
    for (int i = 0; i < n; i++) {
      gcd = __gcd(gcd, ans[i]);
    }
    for (int i = 0; i < n; i++) {
      ans[i] /= gcd;
    }
    lcm = 1;
    for (int i = 0; i < n; i++) {
      lcm = __lcm(lcm, ans[i]);
    }
    for (int i = 0; i < n; i++) {
      std::cout << lcm/ans[i] << std::endl;
    }
  }
  return 0;
}

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

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


void divs(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=1;
		}
	}
}

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;

			divs(d,v);


			ds.push_back(d);
			vs.push_back(v);
		}


		ll z=1;
		ll nums[11];
		ll allv=1;

		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{
			//	if(vs[i-1]!=0)
					z=lcm(z,r1*ds[i-1]/vs[i-1]);
//				else
//					z=1;
				same=false;
			}
		}
		vector<ll> vll;
		ll m;
		if(!same){
			for(ll i = 0; i < n; i++){
				//if(ds[i]!=0){
					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]);
					}
			///	}
			//	else{
				//	vll.push_back(1);
				//	m=1;
			//	}
			}
			for(int i = 0; i < n; i++){
			//	if(m!=0)
					cout<<vll[i]/m<<endl;
				//else
				//	cout<<1<<endl;
			}
		}
		else{
			for(int i = 0; i < n; i++){
				cout<<1<<endl;
			}
		}
	}

	return 0;
}

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

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

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 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 b){
    for (auto & p : b){
        a[p.first] += p.second;
    }
    return a;
}

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

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

mii lcm(mii a, mii 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;
        }
    }
}