Mathematical Love

4

2 votes
Easy, Number Theory
Problem

Romok is the mathematical genius of GCECT. His girlfriend, (not being from the science stream)doesn't like this obsession for Maths. Romok was too tired off such non-mathemetical relationship. As a result they were going away from each other day by day and their relationship was on the verge of BREAKUP. But her heart said something else.She still used to love Romok and was ready to do anything to keep their relationship intact. Having heard this, Romok asked her to solve a problem, just to prove herself eligible of being the girlfriend of Romok(after all he was a mathematical genius). So he gave her N fractions and asked her to find the product of all those fractions in the simplified form.

INPUT :

First line of the input will contain an integer T which denotes the No. of TEST CASES. Next line will contain another integer N which denotes the number of fractions. Next N lines contain two space separated integers A and B where A denotes the Numerator and B denotes the Denominator of the fraction.

OUTPUT :

A single line which will consists of two space separated integers, respectively denoting the numerator and denominator of the simplified fraction after finding the product of all the fractions

NOTE : If the denominator of the result turns out to be 1 do display it as it is, no need of making the fraction an integer

CONSTRAINTS :

1 < = T < = 100

1 < = N < = 10

1 < = A,B < = 20

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?