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

int main(){
	int n;
	ll d[10],v[10],t[10];
	while(cin >> n , n){
		ll g = 1;
		for(int i = 0 ; i < n ; i++){
			cin >> d[i] >> v[i] ;
		}
		for(int i = 0 ; i < n ; i++){
			long long a = v[i];
			for(int j = 0 ; j < n ; j++){
				if(i==j) continue;
				a *= d[j];
			}
			t[i] = a;
		}
		ll w = t[0];
		for(int i = 1 ; i < n ; i++)
			w = gcd(w,t[i]);
		for(int i = 0 ; i < n ; i++)
			cout << t[i] / w << endl;
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-8;
typedef long long ll;
typedef pair<int, int> pint;

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

int n, d[10000], v[10000];
int main()
{
	while (scanf("%d", &n), n)
	{
		for (int i = 0; i < n; ++i)
			scanf("%d%d", d+i, v+i);

		int g;
		ll nume, deno;	// time
		g = gcd(d[0], v[0]);
		nume = d[0] / g;
		deno = v[0] / g;
		for (int i = 1; i < n; ++i)
		{
			g = gcd(d[i], v[i]);
			int td = d[i] / g;
			int tv = v[i] / g;
			nume *= td / gcd(nume, td);
			deno /= deno / gcd(deno, tv);
		}

		for (int i = 0; i < n; ++i)
			printf("%lld\n", (nume*v[i]/deno) / d[i]);
	}

	return 0;
}

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(int 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;
		for(ll i = 0; i < n; i++){
			cin>>d>>v;

			div(d,v);
			ds.push_back(d);
			vs.push_back(v);
		}
		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(int 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<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

long long gozyo(long long a,long long b){
  if(a<b){
    long long temp=a;
    a=b;
    b=temp;
  }
  while(a%b!=0){
    long long  temp=a%b;
    a=b;
    b=temp;
  }
  return b;
}

main(){
  int n;
  long long d[11];
  long long v[11];
  long long a[11];
  long long g;
  long long k1,k2,k3;
  long long t1,t2,t3;
  while( (cin >> n),n ){
    for(int i=0;i<n;i++){
      cin >> d[i] >> v[i];
      g= gozyo(d[i],v[i]);
      d[i]/=g;
      v[i]/=g;
    }



    k1=d[0];
    t1=d[0];
    for(int i=1;i<n;i++){
      k1 = gozyo(t1,d[i]);
      t1=t1*d[i]/k1;
    }

    for(int i=0;i<n;i++) a[i]=t1/d[i]*v[i];

    k2=a[0];
    for(int i=1;i<n;i++) k2 = gozyo(k2,a[i]);

    for(int i=0;i<n;i++){
      cout << a[i]/k2 << endl;
    }
    

  }
}

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;
    int d[11];
    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;
}