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 <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;
const int INF = 1<<29;
const double EPS = 1e-5;

int d[10],v[10];
int x[9],y[9];

int gcd(int x, int y){
    return y ? gcd(y, x%y): x;
}

int lca(int x, int y){
    long long int mul = (long long int)x*y;
    return mul/gcd(x,y);
}

int main(){
    while(1){
        int n;
        scanf("%d",&n);
        if(!n)break;

        for(int i=0;i<n;i++){
            scanf("%d%d",&d[i],&v[i]);
        }

        double left = (double)d[0]/v[0];
        for(int i=0;i<n-1;i++){
            double right = (double)d[i+1]/v[i+1];
            x[i] = 1; y[i] = 1;
            while(abs(x[i]*left-y[i]*right)>EPS){
                if(x[i]*left<y[i]*right) x[i]++;
                else y[i]++;
            }
            //cout << x[i] << " " << y[i] << endl;
        }

        if(n>2){
            int l = 1;
            for(int i=0;i<n-1;i++){
                l = lca(l, x[i]);
            }
            cout << l << endl;
            for(int i=0;i<n-1;i++){
                cout << l / x[i] * y[i] << endl;
            }
        }else{
            cout << x[0] << endl;
            cout << y[0] << endl;
        }

    }

    return 0;
}

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

using namespace std;

long long int gcd(long long int, long long int);
//long long int lcm(long long int, long long int);

int main(){
	int n;
	while (cin >> n, n) {
		vector<int> d(n), v(n);
		for (int i = 0; i < n; i++) {
			cin >> d[i] >> v[i];
		}
		pair<long long int, long long int> cur = make_pair(d[0], v[0]);
		for (int i = 1; i < n; i++) {
			long long int A = cur.first * v[i],
						  B = cur.second * d[i];
			if (A == B) {
				if (cur.second > v[i]) {cur.first = d[i]; cur.second = v[i];}	
				continue;
			} 
			else if (cur.second > v[i]) {cur.first = (A / gcd(A, B)) * d[i]; cur.second = v[i];}
			else {cur.first = (B / gcd(A, B)) * cur.first;}
		}
		for (int i = 0; i < n; i++) {
			cout << (cur.first * v[i]) / (cur.second * d[i]) << endl;	
		}
	}
	return 0;
}

long long int gcd(long long int a, long long int b){
	while (a != b) {
		if (a > b) {
			a = a - b;	
		} else {
			b = b - a;	
		}	
	}
	return a;
	/*
	if (a == b) return a;
	else {
		if (a > b) {
			return gcd(a - b, b);	
		} else {
			return gcd(b - a, a);	
		}	
	}
	*/
}

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

/*
pair<long long int, long long int> func(pair<long long int, long long int> a, pair<long long int, long long int> b){
	long long int A = a.first * b.second, 
		   B = a.second * b.first;
	if (A == B) {
		if (a.second > b.second) {return make_pair(b.first, b.second);}
		else {return make_pair(a.first, a.second);}
	} else {
		if (a.second > b.second){
			return make_pair((A / gcd(A, B)) * b.first, b.second);	
		} else {
			return make_pair((B / gcd(A, B)) * a.first, a.second);	
		}
	}
}
*/

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

llong gcd(llong a, llong b);

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

llong gcd(llong a, llong b){
  if(b > a) swap(a,b);

  llong r = a % b;
  if(r == 0) return b;

  return gcd(b, r);
}

int main(){

  int n;
  while(true){
    scanf("%d", &n);

    if(n == 0) break;

    vector<llong> d(n), v(n);
    REP(i,n){
      scanf("%lld %lld", &d[i], &v[i]);
      llong tmp = gcd(d[i], v[i]);
      d[i] /= tmp; v[i] /= tmp;
    }

    llong D = d[0], V = v[0];
    FOR(i,1,n){
      D = lcm(D, d[i]); V = gcd(V, v[i]);
    }

    REP(i,n){
      printf("%lld\n", D * v[i] / V / d[i]);
    }

  
  }

  return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

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 n;
ll d[10], v[10];

int main() {
	while (cin >> n, n) {
		REP(i, n) scanf("%lld %lld", d + i, v + i);
		
		ll lv = 1;
		REP(i, n) lv = lcm(lv, v[i]);
		REP(i, n) d[i] = d[i] * (lv / v[i]);
		
		ll LCM = 1;
		REP(i, n) LCM = lcm(LCM, d[i]);
		
		REP(i, n) cout << LCM / d[i] << endl;
		
	}
	return 0;
}

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() {
  LLI g = 1;
  for (int i = 0; i < n; ++i) {
    g = lcm(v[i], g);
  }
  for (int i = 0; i < n; ++i) {
    d[i] *= g / v[i];
  }
  g = 1;
  for (int i = 0; i < n; ++i) {
    g = lcm(d[i], g);
  }
  for (int i = 0; i < n; ++i) {
    cout << g / d[i] << endl;
  }
}

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