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

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef vector<Int> vInt;
typedef pair<int,int> pint;
typedef pair<Int,Int> pInt;
typedef vector<string> vstring;
typedef vector<pint> vpint;
typedef vector<pInt> vpInt;
typedef stringstream SS;

template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repn(i,m,n) for(int i=(m);i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;--i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);--i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repn0(i,m,n) for(i=(m);i<(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;--i)
#define repnd0(i,m,n) for(i=(n)-1;i>=(m);--i)
#define repc(i,n) for(int i=0;i<=(n);++i)
#define repcn(i,m,n) for(int i=(m);i<=(n);++i)
#define repcd(i,n) for(int i=(n);i>=0;--i)
#define repcnd(i,m,n) for(int i=(n);i>=(m);--i)
#define repc0(i,n) for(i=0;i<=(n);++i)
#define repcn0(i,m,n) for(i=(m);i<=(n);++i)
#define repcd0(i,n) for(i=(n);i>=0;--i)
#define repcnd0(i,m,n) for(i=(n);i>=(m);--i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define X second
#define Y first
#define p_queue(n) priority_queue<n,vector<n>,greater<n> >
#define PUTLINE cout<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

const int dx[]={1,-1,0,0,1,1,-1,-1,0};
const int dy[]={0,0,1,-1,1,-1,1,-1,0};

vpInt d;

Int gcd(Int a, Int b) {
	return (b == 0) ? a : gcd(b, a % b);
}

pInt gcd(pInt a, pInt b) {
//cout << a.first << " " << a.second << " " << b.first << " " << b.second << endl;
	if (b.first == 0) return a;
	Int n = (a.first * b.second) / (b.first * a.second);
//cout << (a.first * b.second) << " " << (b.first * a.second) << " " << n << endl;
	pInt p;
	p.first = a.first * b.second - b.first * a.second * n;
	p.second = a.second * b.second;
	Int g = gcd(p.first, p.second);
	p.first /= g;
	p.second /= g;
	return gcd(b, p);
}

int main() {
	int n;
	IL {
		cin >> n;
		if (n == 0) break;
		d.clear();
		rep (i, n) {
			int dd, vv;
			cin >> dd >> vv;
			d.PB(MP(dd, vv));
		}
		pInt g, l = d[0];
		repn (i, 1, n) {
			g = gcd(l, d[i]);
			l.first = l.first * d[i].first * g.second;
			l.second = l.second * d[i].second * g.first;
			Int gg = gcd(l.first, l.second);
			l.first /= gg;
			l.second /= gg;
		}
		rep (i, n) {
			cout << l.first * d[i].second / d[i].first / l.second << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
long long int n,L,d[10],v[10],G,f[10];

long long int gcd(long long int x,long long int y) {
  if(y==0) return x;
  return gcd(y ,x%y);
}

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

int main() {
  while(cin >> n) {
    if(n==0) break;
    for(int i=0;i<n;i++) {
      cin >> d[i] >> v[i];
      long long int a = gcd(d[i],v[i]); //yakubun
      d[i] /= a;
      v[i] /= a;
    }

    G = gcd(d[0],d[1]);
    L = lcm(d[0],d[1]);
    for(int i=2;i<n;i++) {
      G = gcd(G,d[i]);
      L = lcm(L,d[i]);
    }
    for(int i=0;i<n;i++) {
      f[i] = L * v[i] / d[i];
    }
    long long int F = gcd(f[0],f[1]);
    for(int i=2;i<n;i++) {
      F = gcd(F,f[i]);
    }
    for(int i=0;i<n;i++) {
      cout << f[i]/F << endl;
    }
  }
}

C++: #include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;

ll n,d[10],v[10],ans;

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


int main(){
	while(cin>>n&&n){
		rep(i,n)cin>>d[i]>>v[i];
		ll l=1;
		rep(i,n-1)l*=d[i+1]*v[0]/gcd(d[0]*l*v[i+1],d[i+1]*v[0]);
		rep(i,n)cout<<l*d[0]*v[i]/d[i]/v[0]<<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>
#include <list>

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

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

template <class T> void max_swap(T& a, const T b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T b) { a = min(a, b); }

const double EPS = 1e-10;
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);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * 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 = lcm(nume, td);
			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<string>
#include<cstdio>
#define int long long
#define P pair<int,int>
using namespace std;

int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {
	return a*b / gcd(a, b);
}
signed main() {
	int a;
	P b[10];
	while (scanf("%lld", &a), a) {
		int LCM = 1;
		for (int c = 0; c < a; c++) {
			int d, e;
			scanf("%lld%lld", &d, &e);
			int f = gcd(d, e);
			b[c] = P(d / f, e / f);
			LCM = lcm(LCM, d / f);
		}
		for (int x = 0; x < a; x++) {
			printf("%lld\n", LCM*b[x].second / b[x].first);
		}
	}
}