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 <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define RFOR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))

using namespace std;

typedef pair<int,int> paii;
typedef long long ll;

int n;
ll dist[100000], vero[100000];

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

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

void solve()
{	
	//dist[]/vero[]

	FOR(i, 0, n)//約分
	{
		ll cd = gcd(dist[i], vero[i]);
		dist[i] /= cd;
		vero[i] /= cd;
	}
	
	ll bs = dist[0];
	
	FOR(i, 0, n)//通分・分母
	{
		bs = lcm(bs, dist[i]);
	}
	
	FOR(i, 0, n)//通分・分子
	{
		vero[i] = vero[i] * (bs / dist[i]);
	}
	
	ll cm = vero[0];
	
	FOR(i, 0, n)//分子の最大公約数
	{
		cm = gcd(cm, vero[i]);
	}
	
	FOR(i, 0, n)
	{
		cout << vero[i]/cm << endl;
	}
	
	return;
}

int main()
{
	
	while(cin >> n, n)
	{
		FOR(i, 0, n)
		{
			cin >> dist[i] >> vero[i];
		}
		
		solve();
	}
	
	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 < d; 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;
		//}
		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);
			}
			else
				z=lcm(z,r1*ds[i-1]/vs[i-1]);
		}
		vector<ll> vll;
		ll m;
		if(z!=1){
			for(ll i = 0; i < n; i++){
				vll.push_back(z*vs[i]/ds[i]);
				if(i==0){
					if(ds[i]==0)
						m=100;
					else
						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];
LLI 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 <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
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(){
      ll n,d[10],v[10];
      while(cin>>n&&n){
            REP(i,n){
                  cin>>d[i]>>v[i];
                  ll a=gcd(d[i],v[i]);
                  v[i]/=a;d[i]/=a;
            }
            ll c=1;
            REP(i,n)c=lcm(c,d[i]);
            REP(i,n)v[i]*=(c/d[i]);
            ll ans=d[0];
            REP(i,n)ans=gcd(ans,v[i]);
            REP(i,n)cout<<v[i]/ans<<endl;
      }
}

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

typedef long long ll;

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

int main(){
  int n;
  ll d[10],v[10],t[10];

  for(;;){
    cin >> n;
    if(!n)break;

    for(int i=0;i<n;i++)cin >> d[i] >> v[i];
    t[0] = 1;
    for(int i=1;i<n;i++){
      t[i] = t[i-1]*d[i-1]*v[i];
      for(int j=0;j<i;j++)t[j] *= d[i]*v[i-1];
      ll T = t[0];
      for(int j=1;j<=i;j++)T = gcd(T,t[j]);
      for(int j=0;j<=i;j++)t[j]/=T;
    }

    for(int i=0;i<n;i++)cout << t[i] << endl;
  }
}

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);
  while(1){
    ll t = a%b;
    a = b;
    b = t;
    if(b == 0)return a;
  }
}

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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <utility>
#include <vector>
using namespace std;
#define debug(x) cout<<#x<<" = "<<x<<endl;

int n;
typedef pair<int,int> data;
typedef long long ll;
vector<data> datas;
ll gcd(const ll a,const ll b){
	return (b>0)? gcd(b, a%b) : a ;
}
ll lcm(const ll a,const ll b){
	return (a / gcd(a, b) * b);
}

void solve(){
  /* 通分 */
  //分母の最小公倍数
  ll lcd=1;//最小公分母

  for(int i=0;i<datas.size();i++){
    lcd=lcm(lcd,datas[i].second);
  }
  ll lcn=1;//最小公分子
  for(int i=0;i<datas.size();i++){
    lcn=lcm(lcn,datas[i].first*lcd/datas[i].second);
  }
  for(int i=0;i<datas.size();i++){
    cout<<lcn/lcd/datas[i].first*datas[i].second<<endl;
  }
}
int main(){
  while(cin >> n,n){
    datas.clear();
    for(int i=0;i<n;i++){
      ll d, v;
      cin >> d >> v;
      datas.push_back(make_pair(d,v));
    }
    solve();
  }
  return 0;
}