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 <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
	int n;
	while(cin>>n,n){
		vector<pll> v(n);
		rep(i,n) cin>>v[i].F>>v[i].S;
		ll g=v[0].S;
		rep(i,n-1){
			g=v[i+1].S/__gcd(g,v[i+1].S)*g;
		}
		// cout<<"g "<<g<<endl;
		rep(i,n){
			ll t=g/v[i].S;
			v[i].F=g/v[i].S*v[i].F;
		}
		ll e=v[0].F;
		rep(i,n-1){
			e=__gcd(e,v[i+1].F);
		}
		rep(i,n){
			cout<<v[i].F/e<<endl;
		}
		continue;
		rep(i,n){
			v[i].F/=e;
		}
		ll f=v[0].F;
		rep(i,n-1){
			f=f/__gcd(f,v[i+1].F)*v[i+1].F;
		}
		// cout<<"f "<<f<<endl;
		// vll ans(n);
		// puts("aaa");
		rep(i,n){
			// ans[i]=f/v[i].F;
			cout<<f/v[i].F<<endl;
		}
		// ll d=ans[0];
		// rep(i,n-1){
			// d=__gcd(d,ans[i+1]);
		// }
		// rep(i,n){
			// cout<<ans[i]/d<<endl;
		// }
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

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 t = GCD(d[i], v[i]);
			d[i] /= t;
			v[i] /= t;
		}
		unsigned long long int dk = d[0];
		unsigned long long int vk = v[0];
		for (int i = 1; i < n; ++i)
		{
			dk = dk * d[i] / GCD(d[i], dk);
			vk = GCD(vk, v[i]);
		}
		for (int i = 0; i < n; ++i)
		{
			cout << (v[i] / vk) * (dk / d[i]) << endl;
		}
	}
}

int main()
{
	solve();
	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> ggg(vector<long long int> v){
    vector<long long int> ret;
    for(int i=0;i<v.size()-1;i++){
	ret.PB(gcd(v[i],v[i+1]));
    }
    return ret;
}

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];
        int n;
        cin >> n;
        vector<long long int> v(n);
	vector<long long int> lc;
        if(!n) break;
        for(int i=0;i<n;i++){
            cin >> d[i] >> v[i];
	    int t = gcd(d[i],v[i]);
	    d[i] = d[i]/t;
	    v[i] = v[i]/t;
	    lc.PB(d[i]);
        }
	long long int dk=d[0];
	long long int vk=v[0];
	for(int i=1;i<n;i++){
	    dk = dk * d[i] / gcd(d[i],dk);
	    vk = gcd(vk,v[i]);
	}
	vector<long long int> ans;
	for(int i=0;i<n;i++){
	    ans.PB((v[i]/vk)*(dk/d[i]));
	}
	for(int i=0;i<n;i++){
	    cout << ans[i]<< endl;
	}
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int n; long long p[10], q[10];
long long gcd(long long x, long long y) {
	return y ? gcd(y, x % y) : x;
}
int main() {
	while(cin >> n, n) {
		for(int i = 0; i < n; i++) {
			cin >> p[i] >> q[i];
			long long r = gcd(p[i], q[i]); p[i] /= r, q[i] /= r;
		}
		long long s = 1;
		for(int i = 0; i < n; i++) s = s / gcd(s, q[i]) * q[i];
		for(int i = 0; i < n; i++) p[i] *= s / q[i]; s = 1;
		for(int i = 0; i < n; i++) s = s / gcd(s, p[i]) * p[i];
		for(int i = 0; i < n; i++) cout << s / p[i] << endl;
	}
}

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

using namespace std;

typedef 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 divs(ll &d,ll &v){
	for(ll i = 2; i <= min(d,v); i++){
		if(d%i==0&&v%i==0){
			d/=i;
			v/=i;
			i=1;
		}
	}
}

int main(){

	ll n;
	while(cin>>n&&n!=0){
		ll d,v;
		vector<ll> ds;
		vector<ll> vs;
		bool oo=false;
		for(ll i = 0; i < n; i++){
			cin>>d>>v;

			divs(d,v);


			ds.push_back(d);
			vs.push_back(v);
		}


		ll z=1;
		ll nums[11];
		ll allv=1;

		bool same=true;
		for(ll 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{
			//	if(vs[i-1]!=0)
				if(r1*ds[i-1]<vs[i-1]){
					z=1;
				}
				else{
					z=lcm(z,r1*ds[i-1]/vs[i-1]);
				}
//				else
//					z=1;
				same=false;
			}
		}
		vector<ll> vll;
		ll m;
		if(!same){
			for(ll i = 0; i < n; i++){
				//if(ds[i]!=0){
					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]);
					}
			///	}
			//	else{
				//	vll.push_back(1);
				//	m=1;
			//	}
			}
			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;
}