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 <string>
#include <vector>
#include <algorithm>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef long long ll;

ll gcd(ll a,ll b)
{
	if(a == 0 || b == 0) return 0;

	while(a != b)
	{
		if(a > b) a -= b;
		else b -= a;
	}
	return a;
}

ll lcm(ll a,ll b)
{
	if(a == 0 || b == 0) return 0;
	return ((a / gcd(a,b)*b));
}

int main()
{
	int n;
	while(cin >> n && n)
	{
		vector<pair<ll,ll> > v;
		
		rep(i,n)
		{
			ll a,b;
			cin >> a >> b;
			v.push_back(make_pair(a,b));
		}

		rep(i,n)
		{
			ll temp = gcd(v[i].first,v[i].second);
			v[i].first /= temp;
			v[i].second /= temp;
		}

		ll t,t2;
		rep(i,n)
		{
			if(i == 0)
			{
				t = v[i].first;
				t2 = v[i].second;
			}
			else
			{
				t = lcm(t,v[i].first);
				t2 = gcd(t2,v[i].second);
			}
		}

		rep(i,n)
		{
			ll ans = t * v[i].second;
			ans /= t2;
			ans /= v[i].first;
			cout << ans << 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);
  if(b == 0)return a;
  gcd(b,a%b);
}

ll lcm(ll a,ll b){
  if(a < b)swap(a,b);
  return (a/gcd(a,b))*b;
}
int main(){
  ll n;
  while(cin >> n , n){

    ll d[n],v[n];
    for(int i = 0 ; i < n ; i++ ){
      cin >> d[i] >> v[i];
    }

    ll dlc = d[0],vlc = v[0];
    for(int i = 1 ; i < n ; i++ ){
      dlc = lcm(dlc,d[i]);
      vlc = lcm(vlc,v[i]);
    }

    ll dd[n];
    for(int i = 0 ; i < n ; i++ ){
      dd[i] = (d[i]*vlc)/v[i];
      }

    ll ddlc = dd[0];
    for(int i = 1 ; i < n ; i++ ){
      ddlc = lcm(ddlc,dd[i]);
    }

    for(int i = 0 ; i < n ; i++ )cout << ddlc/dd[i] << endl;

  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < (n) ; ++i )
#define req(i,n) for(int i = 1 ; i < (n) ; ++i)
typedef long long ll;
int main(){
  int n;
  while(cin >> n , n){
    ll d[n] , v[n];
    rep(i,n) cin >> d[i] >> v[i];
    ll a = d[0];//lcm
    req(i,n) a = d[i]*a / __gcd(d[i],a);
    ll b[n];
    rep(i,n) b[i] = v[i] * a / d[i];
    ll c = b[0];
    req(i,n) c = __gcd(c,b[i]);
    rep(i,n) cout << b[i] / c << endl;;
  }
}

C++: #include <vector>
#include <iostream>
using namespace std;
long long gcd(long long x, long long y){
  if(y > x) swap(x,y);
  if(!y) return x;
  return gcd(y, x%y);
}
              
int main(){
  int n;
  while(cin >> n, n){
    vector<long long> D(n), V(n);
    for(int i = 0; i < n; ++i) cin >> D[i] >> V[i];
    vector<long long> ans(n, 1);
    long long d_ = D[0], v_ = V[0];
    for(int i = 1; i < n; ++i){
      long long d = D[i], v = V[i], g = gcd(v*d_, v_*d);
      ans[i] = d_*v/g;
      for(int j = 0; j < i; ++j){
        ans[j] *= d*v_/g;
      }
      d_ *= d*v_/g;
    }
    for(int i = 0; i < n; ++i) cout << ans[i] << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}
template<class T> T gcd( T a, T b ) {
    return !b ? a : gcd( b, a % b );
}
template<class T> T lcm( T a, T b ) {
    return a / gcd( a, b ) * b;
}


typedef long long LL;
const int SIZE = 11;
int n;
LL D[SIZE], V[SIZE];
LL T[SIZE];

void solve() {
    for ( int i = 0; i < n; ++ i ) {
        LL t = gcd( D[i], V[i] );
        D[i] /= t;
        V[i] /= t;
    }
    LL vgcd = V[0];
    for ( int i = 1; i < n; ++ i ) {
        vgcd = gcd( vgcd, V[i] );
    }
    LL dlcm = D[0];
    for ( int i = 1; i < n; ++ i ) {
        dlcm = lcm( dlcm, D[i] );
    }
    for ( int i = 0; i < n; ++ i ) {
        cout << ( dlcm * V[i] / D[i] / vgcd ) << endl;
    }
    return;
}

int main() {
    while ( cin >> n && n ) {
        for ( int i = 0; i < n; ++ i ) {
            cin >> D[i] >> V[i];
        }
        solve();
    }
    return 0;
}

C++: #include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int INF = 1001001001;

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

int main()
{
	int m;
	while(scanf("%d", &m), m){
		int dist[10], velo[10];
		rep(i, m){
			int a, b;
			scanf("%d%d", &a, &b);
			dist[i] = a / gcd(a, b);
			velo[i] = b / gcd(a, b);
		}
		
		ll n=dist[0], d=velo[0];
		reps(i, 1, m){
			ll nn = n * dist[i];
			ll nd = gcd(n*velo[i], d*dist[i]);
			n = nn / gcd(nn, nd);
			d = nd / gcd(nn, nd);
		}
		rep(i, m){
			printf("%d\n", (n/dist[i])*(velo[i]/d));
		}
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

ll gcd(ll a, ll b){

  while(a){
    b %= a;
    swap(a, b);
  }
  return b;
}

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

int main(void){

  int n,d[10],v[10];
  while( cin >> n , n ){

    for( int i = 0 ; i < n ; i++ ){
      cin >> d[i] >> v[i];
      int dg = gcd(d[i], v[i]);
      d[i] /= dg;
      v[i] /= dg;
    }
    ll gd = v[0], lm = d[0];
    for( int i = 1 ; i < n ; i++ ){
      lm = lcm(lm, d[i]);
      gd = gcd(gd, v[i]);
    }
    for( int i = 0 ; i < n ; i++ )
      cout << lm * v[i] / gd / d[i] << endl;

  }
  return 0;
}