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 <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_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/work)*students[i].distance);
				}
			}
		}

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

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

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

    return 0;
}

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

ll gcd(ll a , ll b){
  if(a < b)swap(a,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 d[10],v[10];

  int n;
  while( cin >> n , n){
    for(int i = 0 ; i < n ; i++ ){
      cin >> d[i] >> v[i];
      ll G = gcd(d[i],v[i]);
      d[i]/=G;
      v[i]/=G;
    }
    ll dlc = d[0];
    for(int i = 1 ; i < n ; i++ ){
      dlc = lcm(dlc,d[i]);
    }
    for(int i = 0 ; i < n ; i++ ){
      v[i] = v[i]*(dlc/d[i]); 
    }
    ll vgc = v[0];
    for(int i = 1 ; i < n ; i++ ){
      vgc = gcd(vgc,v[i]);
    }
    for(int i = 0 ; i < n ; i++ ){
      cout << v[i]/vgc << endl;
    }
  }
  return 0;
}

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

#define lcm(a,b) (a / gcd(a,b) * b)

ll gcd(ll a,ll b){ return b ? gcd(b,a%b) : a; }
ll d[10],v[10],t[10];
int n;

int main(){
	while(cin >> n , n){
		ll g = 1;
		for(int i = 0 ; i < n ; i++)
			cin >> d[i] >> v[i] ;
		ll V = v[0];	
		for(int i = 1 ; i < n ; i++)
			V = lcm(V,v[i]);
		for(int i = 0 ; i < n ; i++)
			d[i] *= V / v[i];
		ll D = d[0];
		for(int i = 1 ; i < n ; i++)
			D = lcm(D,d[i]);
		for(int i = 0 ; i < n ; i++)
			cout << D/d[i] << endl;
		
	}
}

C++: #include<iostream>
using namespace std;
long long n,a[100],b[100],c[100];
long long gcd1;
long long gcd(long long a,long long b){
	if(b==0){return a;}
	return gcd(b,a%b);
}
int main(){
	while(true){
		cin>>n;
		if(n==0){break;}
		gcd1=1;
		for(int i=0;i<n;i++){
			cin>>a[i]>>b[i];
			int GCD2=gcd(a[i],b[i]);
			a[i]/=GCD2;b[i]/=GCD2;
			int GCD=gcd(gcd1,a[i]);
			gcd1=gcd1*a[i]/GCD;
		}
		for(int i=0;i<n;i++){
			c[i]=gcd1*b[i]/a[i];
		}
		int gcd2=c[0];
		for(int i=1;i<n;i++){
			gcd2=gcd(gcd2,c[i]);
		}
		for(int i=0;i<n;i++){
			cout<<c[i]/gcd2<<endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}
template<class T> T gcd( T a, T b ) {
    return !b ? a : gcd( b, a % b );
}
template<class T> T lcm( T a, T b ) {
    return a / gcd( a, b ) * b;
}


typedef long long LL;
const int SIZE = 11;
int n;
LL D[SIZE], V[SIZE];
LL T[SIZE];

void solve() {
    for ( int i = 0; i < n; ++ i ) {
        LL t = gcd( D[i], V[i] );
        D[i] /= t;
        V[i] /= t;
    }
    LL vgcd = V[0];
    for ( int i = 1; i < n; ++ i ) {
        vgcd = gcd( vgcd, V[i] );
    }
    LL dlcm = D[0];
    for ( int i = 1; i < n; ++ i ) {
        dlcm = lcm( dlcm, D[i] );
    }
    for ( int i = 0; i < n; ++ i ) {
        cout << (LL)( (long double)dlcm / vgcd * V[i] / D[i] ) << endl;
    }
    return;
}

int main() {
    while ( cin >> n && n ) {
        for ( int i = 0; i < n; ++ i ) {
            cin >> D[i] >> V[i];
        }
        solve();
    }
    return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

inline ll lcm(ll x, ll y)
{
    return x/__gcd(x,y)*y;
}

int main()
{
    int n;
    while(cin >>n,n)
    {
        vector<ll> d(n),v(n);
        rep(i,n) cin >>d[i] >>v[i];

        ll T=1;
        rep(i,n)
        {
            ll G=__gcd(v[i],d[i]);
            T=lcm(T,d[i]/G);
        }

        vector<ll> ans(n);
        rep(i,n) ans[i]=v[i]*T/d[i];

        ll div=ans[0];
        for(int i=1; i<n; ++i) div=__gcd(div,ans[i]);
        rep(i,n) cout << ans[i]/div << endl;
    }
    return 0;
}