402912: GYM100942 M The smallest fraction

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

M. The smallest fractiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Currently the world knows a great number of sensational archaeological discoveries. Data storage devices relating to the period of programming of the XX century were discovered during recent excavations. Decryption of files allowed scientists to prove the hypothesis that ancient programmers were able to make simple arithmetic operations with fractions. Many texts have been deciphered, many mysteries have been solved. However one problem has remained unsolved: a calculation of the smallest positive fraction that, if divided by each of n given fractions, results in an integer number.

May be you will manage to solve it...

Input

The first line contains an integer n (1 ≤ n ≤ 6). Each of the following n lines contain two integers ai, bi that are numerator and denominator of irreducible fraction (1 ≤ ai ≤ 103,  1 ≤ bi ≤ 109).

Output

Print two positive integers separated by space that are numerator and denominator of the smallest irreducible fraction satisfying the condition of the problem.

ExamplesInput
2
1 2
3 4
Output
3 2
Input
2
2 3
4 5
Output
4 1

加入题单

算法标签: