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
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):
    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 sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

def lcm(a, b):
    return (a // gcd(a, b)) * b

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

    students = [0] * n
    v_lcm = 1
    for i in range(n):
        students[i] = list(map(int, input().split()))
        v_lcm = lcm(v_lcm, students[i][1])
    mul_lcm = 1
    for i in range(n):
        mul_lcm = lcm(mul_lcm, (v_lcm // students[i][1]) * students[i][0])
    for i in range(n):
        print(mul_lcm // (v_lcm // students[i][1]) // students[i][0])

Python: 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):
    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

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 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):
    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: from sys import stdin
readline = stdin.readline


from fractions import Fraction
from fractions import gcd
from functools import reduce

from collections import namedtuple
Runner = namedtuple('Runner', 'd v')

def common_denominator(r0, ri):
    return Fraction(r0.d * ri.v, r0.v * ri.d).denominator

def lcm(a, b):
    return a * b / gcd(a, b)

while True:
    n = int(readline())
    if n == 0:
        break
    runners = [Runner(*map(int, readline().split())) for _ in range(n)]
    
    denominators = [common_denominator(runners[0], ri) for ri in runners[1:]]
    
    round_of_0 = int(reduce(lcm, denominators))
    time = Fraction(runners[0].d * round_of_0, runners[0].v)
    
    for ri in runners:
        print(time * ri.v / ri.d)

Python: def GCD(a,b):
    if min(a,b)==0:
        return max(a,b)
    else:
        return GCD(min(a,b),max(a,b)%min(a,b))

def _LCM(a,b):
    return a*b//GCD(a,b)

def LCM(array):
    lcm=1
    for i in array:
        lcm=_LCM(lcm,i)
    return lcm

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

    d=[]
    v=[]
    for i in range(n):
        _d,_v=[int(j) for j in input().split(" ")]
        d.append(_d)
        v.append(_v)

    V=1
    for i in range(n):
        V=V*v[i]
    array=[d[i]*V//v[i] for i in range(n)]
    lcm=LCM(array)
    for i in range(n):
        print(lcm*v[i]//(V*d[i]))

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):
    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: from fractions import gcd
from functools import reduce
from sys import stdin

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

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

while(True):
    n = int(stdin.readline())
    if not n: break
    s = [list(map(int,stdin.readline().split())) for _ in range(n)]
    lcmde = lcm_list([r[1] for r in s])
    lcmnu = lcm_list([int(r[0]*lcmde/r[1]) for r in s])
    print("\n".join( str(int(lcmnu/lcmde*r[1]/r[0])) for r in s))