Mathematical Love
Practice
4 (2 votes)
Easy
Number theory
Problem
25% Success 785 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

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

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
7 votes
Tags:
MathematicsApprovedEasyGreatest common divisor
Points:20
594 votes
Tags:
Greatest common divisorHiringEasyMathematicsOpenApproved
Points:20
5 votes
Tags:
Number TheoryMathematicsGCDMath