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<string>
#include<vector>
#include<set>
#include<list>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
#include<set>
#define int long long
using namespace std;

int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);;
}
int lcm(int a, int b) {
	return a*b / gcd(a, b);
}
int b[10], c[10];//???????????????
signed main() {
	int a;
	while (cin >> a, a) {
		for (int d = 0; d < a; d++) {
			int e, f; cin >> e >> f;
			e /= gcd(e, f); f /= gcd(e, f);
			b[d] = e; c[d] = f;
		}
		int LCM = 1;
		for (int d = 0; d < a; d++) {
			LCM = lcm(LCM, b[d]);
		}
		for (int d = 0; d < a; d++) {
			cout << c[d] * LCM/b[d] << endl;
		}
	}
}

C++: #include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int main(){
	int n,d[10],v[10],t;
	while(cin>>n,n){
		rep(i,n)cin>>d[i]>>v[i],t=gcd(d[i],v[i]),d[i]/=t,v[i]/=t;
		ll a=d[0],b=v[0];
		rep(i,n)a=lcm(a,d[i]),b=gcd(b,v[i]);
		rep(i,n)cout<<a*v[i]/d[i]/b<<endl;
	}
	return 0;
}

C++: #include<stdio.h>
typedef unsigned long long L;
L GCD(L a,L b){return b?GCD(b,a%b):a;}
L LCM(L a,L b){return a/GCD(a,b)*b;}
int main()
{
	int n,i;
	L v[10],d[10],gcd,lcm,t;
	while(scanf("%d",&n),n)
	{
		lcm=1;
		for(i=0;i<n;++i)
		{
			scanf("%lld%lld",d+i,v+i);
			gcd=GCD(v[i],d[i]);
			v[i]/=gcd;
			d[i]/=gcd;
			lcm=LCM(lcm,v[i]);
		}
		t=1;
		for(i=0;i<n;++i)
			t=LCM(t,lcm/v[i]*d[i]);
		for(i=0;i<n;++i)
			printf("%lld\n",t/d[i]*v[i]/lcm);
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)

typedef long long lint;

lint gcd(lint a, lint b) { return b != 0 ? gcd(b, a % b) : a; }

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

int main() {
	int n;
	
	while (cin >> n, n) {
		vector< lint > d(n), v(n);
		
		cin >> d[0] >> v[0];
		
		lint dd = d[0], vv = v[0];
		
		for_(i,1,n) {
			cin >> d[i] >> v[i];
			lint _lcm_ = lcm(d[i] * vv, v[i] * dd);
			dd = _lcm_ / v[i];
		}
		
		for_(i,0,n) cout << dd * v[i] / (vv * d[i]) << endl;
	}
}

C++: #include<stdio.h>

long long gcd(long long a, long long b){
    if(a == 0)return b;
    return gcd(b % a, a);
}

long long lcm(long long *a, long long *b, long long x, long long y){
    long long d = gcd(x, y);
    x /= d;y /= d;
    *a = *a / gcd(*a, x) * x;
    *b = gcd(*b, y);
}

int main(){
    long long  d[15], v[15], i;
    int n;
    while(scanf("%d", &n), n){
	long long ga = 1, gb = 0;
	for(i = 0;i < n;i++){
	    scanf("%lld%lld", d + i, v + i);
	    lcm(&ga, &gb, d[i], v[i]);
	}
	for(i = 0;i < n;i++){
	    printf("%lld\n", v[i] * ga / gb / d[i]);
	}
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
ll gcd(ll a,ll b){
	return (b==0?a:gcd(b,a%b));
}
ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}
int main(){
	int n;
	while(cin>>n,n){
		vi a(n),b(n);
		rep(i,n)cin>>a[i]>>b[i];
		rep(i,n){
			ll t=gcd(a[i],b[i]);
			a[i]/=t;b[i]/=t;
		}
		ll g=b[0],l=a[0];
		loop(i,1,n){
			g=gcd(g,b[i]);
			l=lcm(l,a[i]);
		}
		rep(i,n)cout<<l/a[i]*(b[i]/g)<<endl;;
	}
}

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);
			//?´??????????
			if(students[i].distance > students[i].speed){
				work = calc(students[i].distance,students[i].speed);
			}else{
				work = calc(students[i].speed,students[i].distance);
			}
			students[i].distance /= work;
			students[i].speed /= work;
		}

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

		//?????????????????§?????????????????????????????????????????????????°???¬?????°????±???????
		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*(students[i].distance/work));
				}else{
					work = calc(students[i].distance,c_distance);
					c_distance = (c_distance*(students[i].distance/work));
				}
			}
		}

		//???????????¨???????±?????????????
		for(int i = 0; i < n; i++){
			students[i].distance = c_distance/students[i].distance;
		}

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

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

    return 0;
}