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
}

Python: """ Created by Jieyi on 10/4/16. """
import io
import sys

if len(sys.argv) > 1:
    filename = sys.argv[1]
    inp = ''.join(open(filename, "r").readlines())
    sys.stdin = io.StringIO(inp)


def gcd(x, y):
    while y:
        x, y = y, x % y

    return x


def lcm(x, y):
    l_lcm = (x * y) // gcd(x, y)
    return l_lcm


def mul_lcm(array):
    l = lcm(array[0], array[1])
    if len(array) > 3:
        for i in range(2, len(array)):
            l = lcm(array[i], l)
    return l


def algorithm(students):
    denominator_lcm = mul_lcm([y for _, y in students])
    for i in range(len(students)):
        students[i][0] *= int(denominator_lcm / students[i][1])
    molecular_lcm = mul_lcm([x for x, _ in students])

    return [int(molecular_lcm / students[i][0]) for i in range(len(students))]


def input_sample():
    while True:
        n = int(input())
        if n == 0:
            break

        students = []
        for _ in range(n):
            students.append(list(map(int, input().split())))
        answer_list = algorithm(students)
        for ans in answer_list:
            print(ans)


def main():
    input_sample()


if __name__ == '__main__':
    main()

Python: import math

def lcm(x, y):
    return int((x * y) / math.gcd(x, y))


def mul_lcm(array):
    l = array[0]
    if len(array) > 1:
        for i in range(1, len(array)):
            l = lcm(array[i], l)

    return l


def algorithm(students, n):
    den = [students[i][1] for i in range(n)]
    denominator_lcm = mul_lcm(den)

    ans = [-1] * 20
    for i in range(n):
        ans[i] = students[i][0] * int(denominator_lcm / students[i][1])
    molecular_lcm = mul_lcm(ans[0:n])

    return [int(molecular_lcm / ans[i]) for i in range(n)]


def input_sample():
    while True:
        n = int(input())
        if n == 0:
            break

        students = [[-1, -1] for _ in range(20)]
        for i in range(n):
            students[i][0], students[i][1] = list(map(int, input().split()))
        answer_list = algorithm(students, n)

        for i in range(n):
            print(answer_list[i])


def main():
    input_sample()


if __name__ == '__main__':
    main()

Python: def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n
def lcm(m, n):
    return m//gcd(m, n)*n
while 1:
    N = int(input())
    if N == 0:
        break
    X = []
    D = []; V = []
    for i in range(N):
        d, v = map(int, input().split())
        g = gcd(d, v)
        d //= g; v //= g
        D.append(d); V.append(v)
    vg = V[0]
    for v in V:
        vg = gcd(vg, v)
    dl = 1
    for d in D:
        dl = lcm(dl, d)
    for d, v in zip(D, V):
        print(v//vg*dl//d)

Python: def gcd(x, y):
    while y:
        x, y = y, x % y

    return x


def lcm(x, y):
    l_lcm = (x * y) // gcd(x, y)
    return l_lcm


def mul_lcm(array):
    l = lcm(array[0], array[1])
    if len(array) > 3:
        for i in range(2, len(array)):
            l = lcm(array[i], l)
    return l


def algorithm(students):
    denominator_lcm = mul_lcm([y for _, y in students])
    for i in range(len(students)):
        students[i][0] *= int(denominator_lcm / students[i][1])

    molecular_lcm = mul_lcm([x for x, _ in students])

    return [int(molecular_lcm / students[i][0]) for i in range(len(students))]


def input_sample():
    while True:
        n = int(input())
        if n == 0:
            break

        students = []
        for _ in range(n):
            students.append(list(map(int, input().split())))
        answer_list = algorithm(students)
        for ans in answer_list:
            print(ans)


def main():
    input_sample()


if __name__ == '__main__':
    main()

Python: """ Created by Jieyi on 10/4/16. """
import io
import sys
from fractions import gcd

if len(sys.argv) > 1:
    filename = sys.argv[1]
    inp = ''.join(open(filename, "r").readlines())
    sys.stdin = io.StringIO(inp)


def lcm(x, y):
    return (x * y) / gcd(x, y)


def mul_lcm(array):
    l = array[0]
    if len(array) > 1:
        for i in range(1, len(array)):
            l = lcm(array[i], l)

    return l


def algorithm(students, n):
    denominator_lcm = mul_lcm([y for _, y in students])
    for i in range(len(students)):
        students[i][0] *= int(denominator_lcm / students[i][1])
    molecular_lcm = mul_lcm([x for x, _ in students])

    return [int(molecular_lcm / students[i][0]) for i in range(len(students))]


def input_sample():
    while True:
        n = int(input())
        if n == 0:
            break

        students = [[-1, -1] for _ in range(20)]
        for i in range(n):
            students[i][0], students[i][1] = list(map(int, input().split()))
        answer_list = algorithm(students, n)

        for i in range(n):
            print(answer_list[i])


def main():
    input_sample()


if __name__ == '__main__':
    main()

Python: """ Created by Jieyi on 10/4/16. """
import io
import sys
from fractions import gcd

if len(sys.argv) > 1:
    filename = sys.argv[1]
    inp = ''.join(open(filename, "r").readlines())
    sys.stdin = io.StringIO(inp)


def lcm(x, y):
    return (x * y) / gcd(x, y)


def mul_lcm(array):
    l = array[0]
    if len(array) > 1:
        for i in range(1, len(array)):
            l = lcm(array[i], l)

    return l


def algorithm(students, n):
    denominator_lcm = mul_lcm([y for _, y in students])
    for i in range(len(students)):
        students[i][0] *= int(denominator_lcm / students[i][1])
    molecular_lcm = mul_lcm([x for x, _ in students])

    return [int(molecular_lcm / students[i][0]) for i in range(len(students))]


def input_sample():
    while True:
        n = int(input())
        if n == 0:
            break

        students = [[-1, -1] for _ in range(10)]
        for i in range(n):
            students[i][0], students[i][1] = list(map(int, input().split()))
        answer_list = algorithm(students, n)

        for i in range(n):
            print(answer_list[i])


def main():
    input_sample()


if __name__ == '__main__':
    main()