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

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

		//?????????????????§?????????????????????????????????????????????????°???¬?????°????±???????
		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/work)*students[i].speed);
				}
			}
		}

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

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

    return 0;
}

C++: #include<iostream>
using namespace std;
int gcd(int a,int b){ return a%b==0 ? b : gcd(b,a%b);}
int main(){
    while(true){
  
    long long int p = 1;
  long long  int d[11];
    long long int v[11];
    int n;
    cin >> n;
    if(!n) break;
 
    for(int i=0;i<n;i++){
        cin >> d[i] >> v[i];
        p *= d[i] / gcd(d[i],v[i]);
  
    }
  
    for(int i=0;i<n;i++){
        cout << v[i]*p/d[i]<<endl; 
    }
   }
    return 0;
}

C++: #include <iostream>
#include <algorithm>

using namespace std;
typedef long long int ll;

ll gcd(ll a,ll b){
  if(a < b)swap(a,b);
  while(1){
    ll t = a%b;
    a = b;
    b = t;
    if(b == 0)return a;
  }
}

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];
    for(ll i = 0 ; i < n ; i++ ){
      cin >> d[i] >> v[i];
      ll cd = gcd(d[i],v[i]);
      d[i]/=cd;
      v[i]/=cd;
    }

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

  }
  return 0;
}

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

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

int n;
data t[10];
ll u[10],size;

ll lcm(ll a,ll b){
  return a/ __gcd(a,b) * b;
}

ll gcd(ll a,ll b){
  return __gcd(a,b);
}

void change(){
  ll x = t[0].d;
  for(int j=1;j<n;j++)x=gcd(x,t[j].d);
  for(int j=0;j<n;j++)t[j].d/=x;
}
void de();

int main(){
  while(cin>>n&&n){
    for(int i=0;i<n;i++){
      cin>>t[i].d>>t[i].v;
      t[i].c();
    }
    change();
    for(int i=1;i<n;i++){
      for(int j=0;j<n;j++)t[j].d*=t[(j+i)%n].v;
      change();
    }//i

    
    for(int i=0;i<n;i++){
      //cout<<t[i].d<<endl;
      
      size=0;

      for(int j=1;j<n;j++){
	ll y = t[(j+i)%n].d;
	y = y / gcd(y,t[i].d);
	for(int k=0;k<size;k++)y=y/gcd(y,u[k]);
	if(y>1)u[size++]=y;
      }


      ll ans=1;
      for(int j=0;j<size;j++)ans*=u[j];
      cout<<ans<<endl;
    }
    
  }
  return 0;
}
void de(){
    /*
    ll y = t[0].d;
    for(int i=1;i<n;i++){
      y=lcm(y,t[i].d);
    }
    for(int i=0;i<n;i++){
      cout<<y/t[i].d<<endl;
    }
    */
}

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

using namespace std;

long int gcd(long int m,long int n){
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    while( m != n )
    {
        if ( m > n ) m = m - n;
        else         n = n - m;
    }
    return m;
}
long int lcm(long int m,long int n)
{
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m / gcd(m, n)) * n);
}

int main() {
    long int d,v,n;
    while (cin >> n) {
        if(n==0) break;
        vector<pair<long int,long int> > data;
        vector<pair<long int,long int> >::iterator it;
        for (int i=0; i<n; i++) {
            cin >> d >> v;
            pair<long int, long int> a(d,v);
            data.push_back(a);
        }
        
        long int v_1,result;
        it = data.begin();
        v_1 = it->second;
        it++;
        result = it->second;
        while(1){
            result = lcm(v_1, result);
            it++;
            if(it == data.end()) break;
            v_1 = it->second;
        }
        
        vector<long int> res;
        vector<long int>::iterator it_res;
        it = data.begin();
        while (it != data.end()) {
            res.push_back(it->first * (result/it->second));
            it++;
        }
        it_res = res.begin();
        v_1 = *it_res;
        it_res++;
        result = *it_res;
        while(1){
            result = lcm(v_1, result);
            it_res++;
            if(it_res == res.end()) break;
            v_1 = *it_res;
        }
        
        it_res = res.begin();
        while (it_res != res.end()) {
            cout << result /(*it_res) << endl;
            it_res++;
        }
    }
    return 0;
}

C++: #include<cstdio>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return (!b)?a:gcd(b,a%b);}
int main(){
int n,i,j;
ll d[10],v[10],t[10];
for(;;){
scanf("%d",&n);
if(!n)break;
for(i=0;i<n;i++)scanf("%lld%lld",&d[i],&v[i]);
t[0]=1;
for(i=1;i<n;i++){
ll T=t[i]=t[i-1]*d[i-1]*v[i];
for(j=0;j<i;j++){
t[j] *= d[i]*v[i-1];
T=gcd(T,t[j]);
}
for(j=0;j<=i;j++)t[j]/=T;
}
for(i=0;i<n;i++)printf("%lld\n",t[i]);
}
}