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++: #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>
using namespace std;
const int INF = INT_MAX / 2;

typedef long long ll;

int N;
ll d[10], v[10];

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(){
	while(cin >> N, N)
	{
		ll lcm1 = 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;
			lcm1 = LCM(lcm1, v[i]);
		}

		ll lcm2 = 1;
		for(int i = 0; i < N; i++)
		{
			d[i] *= lcm1 / v[i];
			v[i] *= lcm1 / v[i];
			lcm2 = LCM(lcm2, d[i]);
		}
		
		for(int i = 0; i < N; i++)
		{
			printf("\t\t%lld\n", lcm2 / d[i]);
		}
	}
	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];
	
	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 <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>

using namespace std;

unsigned long long int GCD(unsigned long long int a, unsigned long long int b)
{
	if (b == 0)
	{
		return(a);
	}
	if (a < b)
	{
		return(GCD(b, a));
	}
	return(GCD(b, a % b));
}

unsigned long long int LCM(unsigned long long int a, unsigned long long int b)
{
	unsigned long long int gcd = GCD(a, b);
	return(a * b / gcd);
}

void solve()
{
	int n;
	while (cin >> n, n)
	{
		vector<unsigned long long int> d(n);
		vector<unsigned long long int> v(n);
		for (int i = 0; i < n; ++i)
		{
			cin >> d[i] >> v[i];
		}
		unsigned long long int lcm = 1;
		vector<unsigned long long int> T(n);
		for (int i = 0; i < n; ++i)
		{
			T[i] = LCM(d[i], v[i]) / v[i];
		}
		unsigned long long int lcmT = T[0];
		unsigned long long int gcdV = v[0];
		for (int i = 1; i < n; ++i)
		{
			lcmT = LCM(lcmT, T[i]);
			gcdV = GCD(gcdV, v[i]);
		}
		for (int i = 0; i < n; ++i)
		{
			cout << v[i] * lcmT / d[i] / gcdV << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

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

typedef struct{
	long long nr,dr;
} Frac;


long long gcd(long long a,long long b){
	if(a % b == 0){
		return b;
	}
	return gcd(b,a%b);
}
long long lcm(long long a,long long b){
	long long g = gcd(a,b);
	return a / g * b;
}

Frac lcm_f(Frac f1,Frac f2){
	long long cdr = lcm(f1.dr,f2.dr);
	long long f1t = cdr / f1.dr;
	long long f2t = cdr / f2.dr;
	long long f1n = f1.nr * f1t;
	long long f2n = f2.nr * f2t;
	long long cnr = lcm(f1n,f2n);
	long long g = gcd(cnr,cdr);
	Frac ret;
	ret.nr = cnr / g;
	ret.dr = cdr / g;
	return ret;
}

long long cal(Frac fr,long long d,long long v){
	return fr.nr * v / fr.dr / d;
}

int main(){
	long long n;
	long long d[11],v[11];
	Frac f[11];
	while(cin >> n,n!=0){
		for(long long i = 0; i < n; i++){
			cin >> d[i] >> v[i];
			f[i].nr = d[i];
			f[i].dr = v[i];
		}
		for(long long i = 1; i < n; i++){
			f[i] = lcm_f(f[i-1],f[i]);
		}
		for(long long i = 0; i < n; i++){
			cout << cal(f[n-1],d[i],v[i]) << 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 V = 1;
    for(int i=0;i<n;i++)V = lcm(V,v[i]);
    ll D = 1;
    for(int i=0;i<n;i++)D = lcm(D,V/v[i]*d[i]);
    
    for(int i=0;i<n;i++){
      cout << (D/d[i])/(V/v[i]) << endl;
    }
  }
}

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*(a/b);
		else
		b-=a*(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++: //26
#include<iostream>

using namespace std;

long long gcd(long long a,long long b){
  return b?gcd(b,a%b):a;
}

int main(){
  for(int n;cin>>n,n;){
    int d[10],v[10];
    for(int i=0;i<n;i++){
      cin>>d[i]>>v[i];
    }
    int m[9];
    for(int i=0;i<n-1;i++){
      m[i]=d[i+1]*v[0]/gcd(d[0]*v[i+1],d[i+1]*v[0]);
    }
    long long f=1;
    for(int i=0;i<n-1;i++){
      f=f*m[i]/gcd(f,m[i]);
    }
    cout<<f<<endl;
    for(int i=1;i<n;i++){
      cout<<f*d[0]*v[i]/v[0]/d[i]<<endl;
    }
  }
  return 0;
}

C++: #include<iostream>

typedef unsigned long long int ll;

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

int main(){
	ll d[10], v[10], m = 1, c = 1;
	int n;
	while(std::cin >> n, n){
		m = c = 1;
		for(int i=0;i<n;i++){
			std::cin >> d[i] >> v[i];
			int g = gcd(m, v[i]);
			m *= v[i] / g;
		}
		for(int i=0;i<n;i++){
			d[i] *= m / v[i];
			int g = gcd(c, d[i]);
			c *= d[i] / g;
		}
		for(int i=0;i<n;i++){
			std::cout << c / d[i] << std::endl;
		}
	}
}