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 <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll inf =1LL << 62;

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(void){
	int n;
	ll runner[10][2];
	ll change[10];
	ll ans[10];
	while(cin >> n,n){
		rep(i,n) cin >> runner[i][0] >> runner[i][1];
		//gcd
		rep(i,n) {
			ll tmp=gcd(runner[i][0],runner[i][1]);
			runner[i][0]/=tmp;
			runner[i][1]/=tmp;
		}
		// lcm
		ll l=runner[0][1];
		rep(i,n-1) l=lcm(l,runner[i+1][1]);
		rep(i,n) change[i]=l/runner[i][1]*runner[i][0];
		//gcd 
		ll g=change[0];
		rep(i,n-1) g=gcd(g,change[i+1]);
		rep(i,n) change[i]/=g;
		// lcm
		l=change[0];
		rep(i,n-1) l=lcm(l,change[i+1]);
		rep(i,n) ans[i]=l/change[i];
		// gcd
		g=ans[0];
		rep(i,n-1) g=gcd(g,ans[i+1]);
		rep(i,n) ans[i]/=g;
		
		rep(i,n) cout << ans[i] << endl;
	}
	return 0;
}

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

int gcd(int a,int b){
	if(a < b) swap(a,b);
	while(b){
		a %= b;
		swap(a,b);
	}
	return a;
}

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

signed main(){
	int n;
	while(cin >> n,n){
		int d[10],v[10],lc = 1;
		for(int i = 0;i < n;i++) {
			cin >> d[i] >> v[i];
			lc = lcm(lc,v[i]);
		}
		for(int i = 0;i < n;i++){
			d[i] = lc / v[i] * d[i];
		}
		lc = 1;
		for(int i = 0;i < n;i++) lc = lcm(lc,d[i]);
		for(int i = 0;i < n;i++) cout << lc / d[i] << endl;
	}
	return 0;
}

C++: //2013/11/25(Mon)

#include <iostream>
using namespace std;

int main()
{
	int  is_prime[10000000];
	is_prime[0] = is_prime[1] = 0;
	for(int i=2; i<10000000; i++)
		is_prime[i] = 1;

	for(int i=2; i*i<10000000; i++){
		if(is_prime[i]){
			for(int j=i*i; j<10000000; j+=i)
				is_prime[j] = -1;
		}
	}
	
	int n;
		
	while(true){
		cin >> n;
		if(n==0)
			break;

		for(int i=n; i>2; i--){
			if(is_prime[i] == 1 && is_prime[i-2] == 1 && is_prime[i-6] == 1 && is_prime[i-8] == 1){
				if(is_prime[i] == is_prime[i-2] && is_prime[i] == is_prime[i-6] && is_prime[i] == is_prime[i-8]){
					cout << i << endl;
					break;
				}
			}
		}
		
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
#define N 10
#define TYPE long long
TYPE gdb(TYPE a,TYPE b){
  if( !b )return a;
  return gdb( b, a%b);
}
TYPE lcm(TYPE a,TYPE b){
  TYPE g = gdb(a,b);
  return a/ g * b;
}
int main(){
  TYPE n,d[N],v[N];
  while(cin>>n,n){
    TYPE t=1, g;

    for( int i=0;i<n;i++ ){
      cin >> d[i] >> v[i];
      t = lcm( v[i] * t, d[i] );
      t  /= v[i];
      g = i==0?d[i]:gdb(g, d[i]);
    }
    if( g!=1 ){
      for( int i=0;i<n;i++ )
	cout << 1 << endl;
    }else{
      for( int i=0;i<n;i++ )
	cout << (v[i]*t/d[i]) << endl;
    }

  }
  return 0;
}

C++: // 2011/08/09 Tazoe

#include <iostream>
using namespace std;

long long GCD(long long m, long long n)
{
	if(n>m){
		long long tmp = m;
		m = n;
		n = tmp;
	}

	if(n==0)
		return m;

	while(true){
		if(m%n==0)
			return n;

		long long tmp = m%n;
		m = n;
		n = tmp;
	}
}

long long LCM(long long m, long long n)
{
	return (m/GCD(m, n))*n;
}

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		long long d[10], v[10];
		for(int i=0; i<n; i++)
			cin >> d[i] >> v[i];

		// v/dªüñ^ÔÆÈé

		// ñª
		for(int i=0; i<n; i++){
			long long gcd = GCD(d[i], v[i]);
			d[i] /= gcd;
			v[i] /= gcd;
		}

		// dÌÅ¬ö{
		long long D = LCM(d[0], d[1]);
		for(int i=2; i<n; i++)
			D = LCM(D, d[i]);

		// üñÌ®»
		long long r[10];
		for(int i=0; i<n; i++)
			r[i] = v[i]*(D/d[i]);

		// rÌÅåöñ
		long long R = GCD(r[0], r[1]);
		for(int i=2; i<n; i++)
			R = GCD(R, r[i]);

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

	return 0;
}

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

typedef long long int LLI;

int n;
LLI d[10];
int 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() {
  LLI g = 1;
  for (int i = 0; i < n; ++i) {
    g = lcm(v[i], g);
  }
  for (int i = 0; i < n; ++i) {
    d[i] *= g / v[i];
  }
  LLI m = gcd(d[0], d[1]);
  for (int i = 2; i < n; ++i) {
    m = gcd(d[i], m);
  }
  for (int i = 0; i < n; ++i) {
    d[i] /= m;
  }
  g = 1;
  for (int i = 0; i < n; ++i) {
    g = lcm(d[i], g);
  }
  for (int i = 0; i < n; ++i) {
    cout << g / d[i] << endl;
  }
}

int main() {
  while (input()) {
    solve();
  }
  return 0;
}