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>
using namespace std;

long long GCD(long long a, long long b) {
    return a == 0 ? b : GCD(b % a, a);
}

long long LCM(long long a, long long b) {
    return a / GCD(a, b) * b;
}

int main() {
    int n;
    while (cin >> n, n) {
        vector<long long> d(n), v(n);
        for (int i=0; i<n; ++i) {
            cin >> d[i] >> v[i];
        }
        long long t = 1;
        for (int i=0; i<n; ++i) {
            t = LCM(t, v[i]);
        }
        for (int i=0; i<n; ++i) {
            d[i] *= t / v[i];
            v[i] = t;
        }
        long long u = 1;
        for (int i=0; i<n; ++i) {
            u = LCM(u, d[i]);
        }
        for (int i=0; i<n; ++i) {
            cout << u / 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*(students[i].speed/work));
				}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++){
			printf("%lld\n",c_distance/students[i].distance);
		}
	}

    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;
}

ll gcd(ll *begin, ll *end) {
	ll res = *begin;
	while (begin != end) res = gcd(res, *begin), ++begin;
	return res;
}

ll lcm(ll *begin, ll *end) {
	ll res = *begin;
	while (begin != end) res = lcm(res, *begin), ++begin;
	return res;
}

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 = gcd(gcd(v, v + n), gcd(d, d + n));
		REP(i, n) d[i] /= g, v[i] /= g;
		
		ll lv = lcm(v, v + n);
		REP(i, n) d[i] *= (lv / v[i]);
		
		ll LCM = lcm(d, d + n);
		ll ans[10];
		REP(i, n) ans[i] = LCM / d[i];
		
		g = gcd(ans, ans + n);
		REP(i, n) ans[i] /= g;
		
		REP(i, n) cout << ans[i] << endl;
		
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;

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

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

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

		vector<lli> d(n),v(n);
		for(int i=0; i<n; i++){
			cin >> d[i] >> v[i];
			lli GCD = gcd(d[i], v[i]);
			if(GCD!=1){
				d[i] /= GCD;
				v[i] /= GCD;
			}
		}
		lli LCM=1;
		for(int i=0; i<n; i++){
			LCM = lcm(LCM, d[i]);
		}
		for(int i=0; i<n; i++){
			v[i] *= LCM / d[i];
		}
		lli GCD = gcd(v[0], v[1]);
		for(int i=2; i<n; i++){
			GCD = gcd(GCD, v[i]);
		}
		for(int i=0; i<n; i++){
			cout << v[i]/GCD << endl;
		}
	}
	return 0;
}

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

ll gcd(ll a,ll b){return (!b)?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll n,d[10],v[10];
  while(cin >> n,n){
    for(int i=0;i<n;i++){
      cin >> d[i] >> v[i];
      ll tmp = gcd(d[i],v[i]);
      d[i]/=tmp; v[i]/=tmp;
    }

    ll ans[10];
    ans[0] = 1;

    for(int i=1;i<n;i++){
      ll x = v[i-1]*d[i], y = v[i]*d[i-1], tmp = gcd(x,y);
      x/=tmp; y/=tmp;      
      tmp = x/gcd(ans[i-1],x);
      for(int j=0;j<i;j++)ans[j] *= tmp;
      ans[i] = ans[i-1]/x*y;
    }

    for(int i=0;i<n;i++){
      cout << ans[i] << endl;
    }
  }
}

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

struct data{
  ll d,v,z,ans;
  void c(){
    ll x = __gcd(d,v);
    d/=x;
    v/=x;
  }
};

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){
    ll y=1;
    for(int i=0;i<n;i++){
      cin>>t[i].d>>t[i].v;
      t[i].c();
      t[i].z=t[i].d;
      y=lcm(y,t[i].v);
    }

    for(int i=0;i<n;i++){
      t[i].d*=y;
      t[i].c();
      //cout<<t[i].d<<' '<<t[i].v<<endl;
    }

    ll m = t[0].v;
    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++: #define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
#include<sstream>
using namespace std;
typedef long long ll;

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 main(){
	ll N;
	while(cin >> N, N)
	{
		ll d[10], v[10], gcdV = 0, lcmD = 1;
		for(int i = 0; i < N; i++)
		{
			cin >> d[i] >> v[i];
			ll gcd = GCD(d[i], v[i]);
			d[i] /= gcd;
			v[i] /= gcd;
			lcmD = LCM(lcmD, d[i]);
			gcdV = GCD(gcdV, v[i]);
		}
		for(int i = 0; i < N; i++)
		{
			printf("%lld\n", v[i] / gcdV * (lcmD / d[i]));
	}
	}
}