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>

using namespace std;

typedef unsigned long long ull;

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

int main()
{
	for(int n;cin>>n,n;){
		vector<ull> ds(n),vs(n);
		for(int i=0;i<n;i++)
			cin>>ds[i]>>vs[i];
		
		ull a=1;
		for(int i=0;i<n;i++)
			a=lcm(a,vs[i]);
		ull b=1;
		for(int i=0;i<n;i++)
			b=lcm(b,ds[i]*(a/vs[i]));
		
		for(int i=0;i<n;i++)
			cout<<b/ds[i]/(a/vs[i])<<endl;
	}
	
	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++){
      t[i] = t[i-1]*d[i-1]*v[i];
      for(j=0;j<i;j++)t[j] *= d[i]*v[i-1];
      ll T = t[0];
      for(j=1;j<=i;j++)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]);
  }
}

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

using namespace std;

typedef unsigned long long BigInt;

BigInt gcd(BigInt a, BigInt b) {
  if (a < b) {
    swap(a, b);
  }
  while (b > 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}

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

int main() {
  int n;
  BigInt dh, vh;
  BigInt d[10], v[10];
  while (true) {
    cin >> n;
    if (n == 0) {
      return 0;
    }
    for (int i = 0; i < n; ++i) {
      cin >> d[i] >> v[i];
    }
    dh = d[0];
    vh = v[0];
    for (int i = 1; i < n; ++i) {
      BigInt y = lcm(v[i] * dh, vh * d[i]);
      BigInt kh = y / (v[i] * dh);
      BigInt z = gcd(dh * kh, vh);
      dh = dh * kh / z;
      vh /= z;
    }
    for (int i = 0; i < n; ++i) {
      cout << dh * v[i] / (d[i] * vh) << endl;
    }
  }
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef unsigned long long int lli;
struct student{
  int d, v;
};
vector<student> vs;

lli __gcd(lli a, lli b){
  if(b == 0)return a;
  return __gcd(b, a%b);
}
lli __lcm(lli a, lli b){
  return a/__gcd(a, b)*b;
}
int main(int argc, char *argv[]){
  int n;
  while(std::cin >> n, n){
    vs.clear();
    lli lcm_v = 1, lcm = 1;
    for (int i = 0; i < n; i++) {
      student s;
      std::cin >> s.d >> s.v;
      vs.push_back(s);
    }
    for (int i = 0; i < n; i++) {
      lcm_v = __lcm(lcm_v, vs[i].v);
    }
    //lli tlcm_v = lcm_v;
    for (int i = 0; i < n; i++) {
      lcm = __lcm(lcm, lcm_v/vs[i].v*vs[i].d);
      // lli gcd  = __gcd(tlcm_v, lcm);
      // lcm /= gcd;
      // tlcm_v /= gcd;
    }
    // std::cout << "  lcm:" << lcm   << std::endl;
    // std::cout << "lcm_v:" << lcm_v << std::endl;
    for (int i = 0; i < n; i++) {
      std::cout << (lcm*vs[i].v)/(lcm_v*vs[i].d)<< std::endl;
    }
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#define PB push_back
using namespace std;

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

vector<long long int> lcm(vector<long long int> v){
    vector<long long int> ret;
    for(int i=0;i<v.size()-1;i++){
	ret.PB(v[i]*v[i+1]/gcd(v[i],v[i+1]));
    }
    return ret;
}
int main(){
    while(true){
        long long int p = 1;
        long long  int d[11];
        long long int v[11];
	vector<long long int> lc;
        int n;
        cin >> n;
        if(!n) break;
        for(int i=0;i<n;i++){
            cin >> d[i] >> v[i];
	    lc.PB(d[i]/gcd(d[i],v[i]));
        }
	while(lc.size()>1){
	    lc = lcm(lc);
	}
	p = lc[0];
	bool flg = true;
	for(int i=0;i<n;i++){
	    if(p % d[i] == 0){
		flg = false;
		break;
	    }
	}
	
	vector<long long int> ans;
	bool flg = true;
	for(int i=0;i<n;i++){
	    ans.PB(v[i]*p/d[i]);
	}
	for(int i=0;i<n;i++){
	    for(int j=i+1;j<n;j++){
		if(ans[i]!=ans[j]) flg = false;
	    }
	}
	if(flg){
	    for(int i=0;i<n;i++){
		cout << ans[i] << endl;
	    }
	}else{
	    for(int i=0;i<n;i++){
		cout << 1 << endl;
	    }
	}
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
typedef long long int llf;
vector<int> p;
llf gcd(llf a,llf b){
	while(a!=b){
		if(max(a,b)%min(a,b)==0)
		return min(a,b);
		if(a>b)
		a-=b;
		else
		b-=a;
	}
	return a;
}
llf gcd(llf c[10],int n){
	llf d[10];
	for(int i=0;i<n;i++)
	d[i]=c[i];
	llf x=d[0];
	for(int i=1;i<n;i++)
	x=gcd(x,d[i]);
	return x;
}
llf lcm(llf c[10],int n){
	int d[10];
	for(int i=0;i<10;i++)
	d[i]=c[i];
	int times[10000]={};
	for(int i=0;i<n;i++){
		for(int j=0;j<p.size();j++){
			int k=0;
			while(d[i]%p[j]==0){
				d[i]/=p[j];
				k++;
			}
			times[p[j]]=max(times[p[j]],k);
		}
	}
	llf ans=1;
	for(int i=0;i<p.size();i++)
		for(int j=0;j<times[p[i]];j++)
			ans*=p[i];
	return ans;
}
int main() {
	// your code goes here
	p.push_back(2);
	for(int i=3;i<=10000;i++){
		for(int j=0;j<p.size();j++){
			if(i%p[j]==0)
			break;
			if(j==p.size()-1)
			p.push_back(i);
		}
	}
	int n;
	while(cin >> n && n!=0){
		llf d[10],v[10];
		for(int i=0;i<n;i++)
		cin >> d[i] >> v[i];
		llf times=lcm(d,n);
		for(int i=0;i<n;i++)
		v[i]*=(times/d[i]);
		llf c=gcd(v,n);
		for(int i=0;i<n;i++)
		cout << v[i]/c << endl;
	}
	return 0;
}

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

using namespace std;

typedef 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 divs(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=1;
		}
	}
}

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;

			divs(d,v);


			ds.push_back(d);
			vs.push_back(v);
		}


		ll z=1;
		ll nums[11];
		ll allv=1;

		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{
			//	if(vs[i-1]!=0)
					z=lcm(z,r1*ds[i-1]/vs[i-1]);
//				else
//					z=1;
				same=false;
			}
		}
		vector<ll> vll;
		ll m;
		if(z==0)
			continue;
		if(!same){
			for(ll i = 0; i < n; i++){
				//if(ds[i]!=0){
					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]);
					}
			///	}
			//	else{
				//	vll.push_back(1);
				//	m=1;
			//	}
			}
			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;
}