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 <stdio.h>
#include <stack>
#include <math.h>

using namespace std;

long long calc(long long x,long long y){
	if(y == 0){
		return x;
	}else{
		return calc(y,x%y);
	}
}

struct Student{
	long long int distance,speed;
};

int main(){

	int n;
	long long int c_speed,c_distance,work;
	Student students[10];

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		for(int i= 0; i < n; i++){
			scanf("%lld %lld",&students[i].distance,&students[i].speed);
			//?´??????????
			if(students[i].distance > students[i].speed){
				work = calc(students[i].distance,students[i].speed);
			}else{
				work = calc(students[i].speed,students[i].distance);
			}
			students[i].distance /= work;
			students[i].speed /= work;
		}

		//?????????????°???¬?????°????±???????

		//?????????????????§?????????????????????????????????????????????????°???¬?????°????±???????
		for(int i=0; i < n; i++){
			if(i == 0){
				c_speed = students[i].speed;
			}else{
				if(c_speed >= students[i].speed){
					work = calc(c_speed,students[i].speed);
					c_speed = ((c_speed/work)*students[i].speed);
				}else{
					work = calc(students[i].speed,c_speed);
					c_speed = (c_speed*(students[i].speed/work));
				}
			}
		}

		//??????????????????????????????????????????
		for(int i=0; i < n; i++){
			students[i].distance *= (c_speed/students[i].speed);
		}

		//?¬?????????????????°???¬?????°????±???????
		for(int i=0; i < n; i++){
			if(i == 0){
				c_distance = students[i].distance;
			}else{
				if(c_distance >= students[i].distance){
					work = calc(c_distance,students[i].distance);
					c_distance = ((c_distance/work)*students[i].distance);
				}else{
					work = calc(students[i].distance,c_distance);
					c_distance = (c_distance*(students[i].distance/work));
				}
			}
		}

		for(int i=0; i < n; i++){
			printf("%lld\n",c_distance/students[i].distance);
		}
	}

    return 0;
}

C++: #include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

#define MAX 10
typedef long long ll;

ll d[MAX],v[MAX];

ll gcd(ll a,ll b){
  return __gcd(a,b);
}

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

int main(){
  int n;

  while(scanf("%d" ,&n) ,n){
    scanf("%lld %lld" ,&d[0] ,&v[0]);
    
    ll V = v[0];
    for(int i = 1 ; i < n ; i++){
      scanf("%lld %lld" ,&d[i] ,&v[i]);

      for(int j = 2 ; j <= min(d[i],v[i]) ; j++){
	if(d[i] % j == 0 || v[i] % j == 0){
	  while(d[i] % j == 0 && v[i] % j == 0){
	    d[i] /= j;
	    v[i] /= j;
	  }
	}
      }
    }       
    
    ll T = d[0];
    for(int i = 1 ; i < n ; i++){
      T = lcm(T,d[i]);
      V = gcd(V,v[i]);
    }
    
    for(int i = 0 ; i < n ; i++){
      ll div = T / d[i];
      printf("%lld\n" ,div*v[i]/V);
    }
  }
  
  return 0;
}

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++: #define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;

static const int tx[] = {+0,+1,+0,-1};
static const int ty[] = {-1,+0,+1,+0};

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;
}

class Student {
public:
  ll distance;
  ll velocity;
  Student(ll distance,ll velocity) 
    : distance(distance), velocity(velocity) {}
};

int main(){
  int total_students;
  while(~scanf("%d",&total_students)){
    if(total_students == 0) break;

    vector<Student> students;
    for(int student_i = 0; student_i < total_students; student_i++){
      ll distance;
      ll velocity;
      scanf("%lld %lld",&distance,&velocity);
      int gcd = GCD(distance,velocity);
      students.push_back(Student(distance / gcd,velocity / gcd));
    }

    ll reference_distance = students[0].distance;
    for(int student_i = 0; student_i < total_students; student_i++){
      reference_distance = LCM(reference_distance,
                               students[student_i].distance);

    }

    for(int student_i = 0; student_i < total_students; student_i++){
      students[student_i].velocity
        = students[student_i].velocity * (reference_distance / students[student_i].distance);
    }

    ll gcd = students[0].velocity;
    for(int student_i = 0; student_i < total_students; student_i++){
      gcd = GCD(gcd,students[student_i].velocity);
    }
        
    for(int student_i = 0; student_i < total_students; student_i++){
      printf("%lld\n",students[student_i].velocity / gcd);
    }
  }
}