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

using namespace std;

long long int gcd(long long int);
//long long int lcm(long long int, long long int);
pair<long long int, long long int> func(pair<long long int, long long int>, pair<long long int, long long int>);

int main(){
	int n;
	while (cin >> n, n) {
		vector<pair<long long int, long long int> > data;
		vector<long long int> p_lcm;
		for (int i = 0; i < n; i++) {
			int d, v; cin >> d >> v;
			data.push_back(make_pair((long long int)d, (long long int)v));
		}
		pair<long long int, long long int> cur = make_pair(data[0].first, data[0].second);
		for (int i = 1; i < data.size(); i++) {
			cur = func(cur, data[i]);
		}
		for (int i = 0; i < data.size(); i++) {
			cout << (cur.first * data[i].second) / (cur.second * data[i].first) << 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 <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 g = d[0];
		REP(i, n) g = gcd(g, gcd(d[i], v[i]));
		REP(i, n) d[i] /= g, v[i] /= g;
		
		ll lv = 1;
		REP(i, n) lv = lcm(lv, v[i]);
		REP(i, n) d[i] *= (lv / v[i]);
		
		ll LCM = 1;
		REP(i, n) LCM = lcm(LCM, d[i]);
		
		ll ans[10];
		REP(i, n) ans[i] = LCM / d[i];
		
		g = ans[0];
		REP(i, n) g = gcd(g, ans[i]);
		REP(i, n) ans[i] /= g;
		
		REP(i, n) cout << ans[i] << endl;
		
	}
	return 0;
}

C++: #include <iostream>

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

int main(){
	int n;
	while (std::cin >> n, n){
		ll d[11], v[11], mul = 1;
		for (int i = 0; i < n; ++i){
			std::cin >> d[i] >> v[i];
			ll g = gcd(d[i], v[i]);
			d[i] /= g, v[i] /= g;
			mul = lcm(mul, v[i]);
		}
		for (int i = 0; i < n; ++i)d[i] *= (mul / v[i]);
		ll 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)std::cout << t / d[i] << std::endl;
	}
	return 0;
}

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

long long lcm(long long a,long long b) {
	long long c;
	if (a<b) { c=a; a=b; b=c;}
	while(a % b!=0) {c=a; a=b; b=c % b;}
	return b;
}

int main() {
	long long d[10],v[10],a,c,e,f;
	int i,n;
	while(cin >> n && n>0) {
		for (i=0;i<n;i++) cin >> d[i] >> v[i];
		e=d[0]; f=v[0];
		for (i=1;i<n;i++) {
			c=lcm(f*d[i],e*v[i]);
			a=e*v[i]/c;
			e=a*d[i]; f=v[i];
			};
		for (i=0;i<n;i++) cout << (e*v[i])/(f*d[i]) << endl;
	} 
	return 0;
}

C++: #include <stdio.h>
#include <stack>
#include <math.h>

using namespace std;

long long calc(long long x,long long y){
	if(y == 0){
		return x;
	}else{
		return calc(y,x%y);
	}
}

struct Student{
	long long int distance,speed;
};

int main(){

	int n;
	long long int c_speed,c_distance,work;
	Student students[10];

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		for(int i= 0; i < n; i++){
			scanf("%lld %lld",&students[i].distance,&students[i].speed);
		}

		//?????????????°???¬?????°????±???????

		//?????????????????§?????????????????????????????????????????????????°???¬?????°????±???????
		for(int i=0; i < n; i++){
			if(i == 0){
				c_speed = students[i].speed;
			}else{
				if(c_speed >= students[i].speed){
					work = calc(c_speed,students[i].speed);
					c_speed = ((c_speed/work)*students[i].speed);
				}else{
					work = calc(students[i].speed,c_speed);
					c_speed = (c_speed*(students[i].speed/work));
				}
			}
		}

		//??????????????????????????????????????????
		for(int i=0; i < n; i++){
			students[i].distance *= (c_speed/students[i].speed);
		}

		//?¬?????????????????°???¬?????°????±???????
		for(int i=0; i < n; i++){
			if(i == 0){
				c_distance = students[i].distance;
			}else{
				if(c_distance >= students[i].distance){
					work = calc(c_distance,students[i].distance);
					c_distance = ((c_distance/work)*students[i].distance);
				}else{
					work = calc(students[i].distance,c_distance);
					c_distance = (c_distance*(students[i].distance/work));
				}
			}
		}

		for(int i=0; i < n; i++){
			printf("%lld\n",c_distance/students[i].distance);
		}
	}

    return 0;
}