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>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

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

const int INF = 1 << 24;

ll gcd(ll x, ll y){
    //cout << "gcd now x = " << x << "y = " << y<< endl;
    return y ? gcd(y, x % y):x;
}

ll lcm(ll x, ll y){
    //cout << "lcm now" << endl;
    return x * y / gcd(x, y);
}

int main(void){
    for(int n; cin >> n, n;){
        vi d(n), v(n);
        rep(i, n) cin >> d[i] >> v[i];

        rep(i, n){
            int res = 1;
            COUNT(j, n - 1){
                int ind = (i + j) % n;
                res = lcm(res, v[i] * d[ind] / gcd(v[ind] * d[i], v[i] * d[ind]));
            }
            cout << res << endl;
        }
    }

    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }


ll gcd(ll x, ll y)
{    return y ? gcd(y, x % y) : x;	}

ll lcm(ll x, ll y)
{    return x * y / gcd(x, y);		}

int main()
{
    int n;
    while(cin >> n && n)
    {
		vint D(n), V(n);
		
		rep(i, n)
		{
			cin >> D[i] >> V[i];
			
			int gd = gcd(D[i], V[i]);
			D[i] /= gd;
			V[i] /= gd;
		}
    
		ll gd = V[0], lm = D[0];
		REP(i, 1, n)
		{
			lm = lcm(lm, D[i]);
			gd = gcd(gd, V[i]);
		}
		
		rep(i, n) cout << lm * V[i] / gd / D[i] << endl;
	}
}

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++){
      for(long long j=1;;j++){
	if(j*d[0]*v[i+1]%(v[0]*d[i+1])==0){
	  m[i]=j;
	  break;
	}
      }
    }
    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>
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;
    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;
}

C++: #include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>

using namespace std;

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

#ifdef __BORLANDC__
	typedef __int64 ll;
#else 
	typedef long long ll;
#endif


int n;
vector<int> d;
vector<int> s;
bool input(){
	cin>>n;
	if(n==0)return false;
	d=vector<int>(n);
	s=vector<int>(n);
	rep(i,n){
		cin>>d[i]>>s[i];
	}
	return true;
}

typedef pair<ll,ll> pll;


ll gcd(ll a, ll b){
	if(a<b)swap(a,b);
	
	while(1){
		ll c = a%b;
		if(b==0){
			while(1)printf("hello");
		}
		if(c==0)return b;
		a = b;
		b = c;
	}
	return -1;
}
pll tubun(pll a){
	ll gc = gcd(a.first, a.second);
	a.first/=gc;
	a.second/=gc;
	return a;
}
ll lcm(ll a, ll b, ll c, ll d){
	pll tes1 = tubun(pll(a,b));
	pll tes2 = tubun(pll(c,d));
	
	a = tes1.first;  b = tes1.second;
	c = tes2.first;  d = tes2.second;
	
	
	ll bunbo = b*d;
	ll A = a*d;
	ll B = b*c;
	ll C = gcd(A,B);
	ll bunshi = A/C * B/C * C;
	
	return bunshi/bunbo;
}

const int N = 10;

vector<int> solve(){
	vector<int> ret;
	
	rep(i,n){
		pll hoge = tubun(pll(d[i],s[i]));
		d[i] = hoge.first;
		s[i] = hoge.second;
	}
	
	ll mygcd = gcd(s[0],s[1]);
	reps(i,2,n)mygcd = gcd(mygcd, s[2]);
	rep(i,n)s[i]/=mygcd;
	
	ll mylcm = lcm(d[0],s[0],d[1],s[1]);
	reps(i,2,n){
		mylcm = lcm(mylcm, 1, d[i], s[i]);
	}
	
	rep(i,n){
		ret.push_back((int)(mylcm/d[i]*s[i]));
	}
	
	return ret;
}

void c_solve(){
	vector<int> ans = solve();
	rep(i,ans.size())cout<<ans[i]<<endl;
}

int main(){
	while(input())c_solve();	
}