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++: 
import java.util.*;
import java.io.*;
import java.math.BigInteger;

import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt();
			if(n == 0) break;
			BigInteger[] d = new BigInteger[n], v = new BigInteger[n];
			d[0] = new BigInteger(sc.next()); v[0] = new BigInteger(sc.next());
			
			BigInteger div = gcd(d[0], v[0]);
			d[0] = d[0].divide(div); v[0] = v[0].divide(div);
			
			BigInteger nume = new BigInteger("" + d[0]), deno = new BigInteger("" + v[0]);
			for(int i=1;i<n;i++) {
				d[i] = new BigInteger(sc.next()); v[i] = new BigInteger(sc.next());
				div = gcd(d[i], v[i]);
				d[i] = d[i].divide(div); v[i] = v[i].divide(div);
				nume = lcm(nume, d[i]);
				deno = gcd(deno, v[i]);
			}
			for(int i=0;i<n;i++) {
				System.out.println(nume.divide(d[i]).multiply(v[i]).divide(deno) );				
			}
		}
	}
	
	BigInteger lcm(BigInteger x, BigInteger y) {
		return x.divide(gcd(x, y)).multiply(y);
	}
	
	BigInteger gcd(BigInteger x, BigInteger y) {
		if(y.equals(new BigInteger("0"))) return x;
		return gcd(y, x.divideAndRemainder(y)[1]);
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  int n;
  while (cin >> n) {
    if (n == 0)
      break;

    vector<long long int> d(n), v(n);
    for (int i = 0; i < n; ++i) {
      cin >> d[i] >> v[i];
      long long int gcd = __gcd(d[i], v[i]);
      d[i] /= gcd;
      v[i] /= gcd;
    }

    long long int lcm = d[0], gcd = v[0];
    for (int i = 1; i < n; ++i) {
      lcm = lcm / __gcd(lcm, d[i]) * d[i];
      gcd = __gcd(gcd, v[i]);
    }

    for (int i = 0; i < n; ++i)
      cout << lcm / d[i] * v[i] / gcd << endl;
  }
  return 0;
}

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;
	while(scanf("%d",&n),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);
	}
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

struct data{
  ll d,v,D,V;
  void c(){
    ll x = __gcd(d,v);
    d/=x;
    v/=x;
  }
  void cp(){
    D=d,V=v;
  }
};

int n;
data t[10];

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

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

int main(){
  while(cin>>n&&n){
    for(int i=0;i<n;i++){
      cin>>t[i].d>>t[i].v;
      t[i].c();
      t[i].cp();
    }
    
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	t[i].d*=t[j].V;
	t[i].c();
      }
      //cout<<t[i].d<<' '<<t[i].v<<endl;
    }//i
    ll m = 1;
    for(int i=0;i<n;i++){
      m=lcm(m,t[i].d);
    }
    for(int i=0;i<n;i++){
      cout<<m/t[i].d<<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;
    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 <iostream>
using namespace std;

typedef long long int LLI;

int n;
LLI d[10];
int v[10];

bool input() {
  cin >> n;
  if (!n) {
    return false;
  }
  for (int i = 0; i < n; ++i) {
    cin >> d[i] >> v[i];
  }
  return true;
}

LLI gcd(LLI a, LLI b) {
  if (a < b) {
    return gcd(b, a);
  }

  while (b) {
    LLI t = a % b;
    a = b;
    b = t;
  }
  return a;
}

LLI lcm(LLI a, LLI b) {
  LLI g = gcd(a, b);
  return a / g * b;
}

void solve() {
  for (int i = 0; i < n; ++i) {
    LLI m = gcd(d[i], v[i]);
    d[i] /= m;
    v[i] /= m;
  }
  LLI g = 1;
  for (int i = 0; i < n; ++i) {
    g = lcm(g, v[i]);
  }
  for (int i = 0; i < n; ++i) {
    d[i] *= g / v[i];
  }
  g = 1;
  for (int i = 0; i < n; ++i) {
    g = lcm(g, d[i]);
  }
  for (int i = 0; i < n; ++i) {
    cout << g / d[i] << endl;
  }
}

int main() {
  while (input()) {
    solve();
  }
  return 0;
}