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

using namespace std;

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


void div(ll &d,ll &v){
	for(ll i = 2; i < min(d,v); i++){
		if(d%i==0&&v%i==0){
			d/=i;
			v/=i;
			i--;
		}
	}
}

int main(){

	ll n;
	while(cin>>n&&n!=0){
		ll d,v;
		vector<ll> ds;
		vector<ll> vs;
		bool oo=false;
		for(ll i = 0; i < n; i++){
			cin>>d>>v;

			div(d,v);
			if(d==0||v==0){
				cout<<"ee"<<endl;
				oo=true;
				break;
			}
			ds.push_back(d);
			vs.push_back(v);
		}
		if(oo)
			break;
		ll z=1;
		ll nums[11];
		ll allv=1;
		//for(ll i = 0; i < n; i++){
		//	allv*=vs[i];
		//}

		//for(ll i = 0; i < n; i++){
		//	nums[i]=ds[i]*allv/vs[i];
		//	z=lcm(z,nums[i]);
		//}
		//for(ll i = 0; i < n; i++){
		//	cout<<(z/nums[i])<<endl;
		//}
		bool same=true;
		for(ll i = 1; i < n; i++){
			ll n1=ds[i-1]*vs[i];
			ll n2=ds[i]*vs[i-1];
			ll ret=lcm(n1,n2);
			ll r1=ret/n1;
			ll r2=ret/n2;
			if(ds[i-1]==ds[i]&&vs[i-1]==vs[i]){
				z=lcm(z,1);
				same=true;
			}
			else{
				z=lcm(z,r1*ds[i-1]/vs[i-1]);
				same=false;
			}
		}
		vector<ll> vll;
		ll m;
		if(!same){
			for(ll i = 0; i < n; i++){
				vll.push_back(z*vs[i]/ds[i]);
				if(i==0){
					m=z*vs[i]/ds[i];
				}
				else{
					m=gcd(m,z*vs[i]/ds[i]);
				}
			}
			for(int i = 0; i < n; i++){
				cout<<vll[i]/m<<endl;
			}
		}
		else{
			for(int i = 0; i < n; i++){
				cout<<1<<endl;
			}
		}
	}

	return 0;
}

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

typedef long long int LLI;

int n;
LLI d[10];
int v[10];

bool input() {
  cin >> n;
  if (!n) {
    return false;
  }
  for (int i = 0; i < n; ++i) {
    cin >> d[i] >> v[i];
  }
  return true;
}

LLI gcd(LLI a, LLI b) {
  if (a < b) {
    return gcd(b, a);
  }

  while (b) {
    LLI t = a % b;
    a = b;
    b = t;
  }
  return a;
}

LLI lcm(LLI a, LLI b) {
  LLI g = gcd(a, b);
  return a / g * b;
}

void solve() {
  for (int i = 0; i < n; ++i) {
    LLI m = gcd(d[i], v[i]);
    d[i] /= m;
    v[i] /= m;
  }
  LLI g = d[0];
  for (int i = 1; i < n; ++i) {
    g = lcm(g, d[i]);
  }
  for (int i = 0; i < n; ++i) {
    v[i] *= g / d[i];
  }
  g = v[0];
  for (int i = 1; i < n; ++i) {
    g = gcd(g, v[i]);
  }
  for (int i = 0; i < n; ++i) {
    v[i] /= g;
  }
  for (int i = 0; i < n; ++i) {
    cout << v[i] << endl;
  }
}

int main() {
  while (input()) {
    solve();
  }
  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);
			//?´??????????
			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/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++){
			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);
				}
			}
		}

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



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

    return 0;
}

C++: #include <cstdio>
#include <utility>
using namespace std;
typedef pair<int,int> P;
int d[10],v[10];
P p[9];
int gcd(int a,int b) {
	return b?gcd(b,a%b):a;
}
int lcm(int a,int b) {
	return a/gcd(a,b)*b;
}
int main() {
	int n;
	while(scanf("%d",&n),n) {
		for(int i=0;i<n;i++) {
			scanf("%d %d",&d[i],&v[i]);
		}
		for(int i=0;i+1<n;i++) {
			int x=v[i]*d[i+1],y=d[i]*v[i+1],g=gcd(x,y);
			p[i]=P(x/g,y/g);
		}
		int m=n-1;
		for(int i=0;i+1<m;i++) {
			int l=lcm(p[i].second,p[i+1].first);
			p[i+1].second*=(l/p[i+1].first);
			for(int j=0;j<=i;j++)
				p[j].first*=(l/p[i].second);
			p[i].second=p[i+1].first=l;
		}
		int g=p[m-1].second;
		for(int i=0;i<m;i++) {
			g=gcd(g,p[i].first);
		}
		for(int i=0;i<m;i++) {
			printf("%d\n",p[i].first/g);
		}
		printf("%d\n",p[m-1].second/g);
	}
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
typedef int 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;
}

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