Fraction Trouble
Submissions: 54   Accuracy:

33.33%

  Difficulty: Easy   Marks: 2

Consider the set of irreducible fractions A = {n/d | n≤d and d ≤ 10000 and gcd(n,d) = 1}.

You are given a member of this set and your task is to find the largest fraction in this set less than the given fraction.

Note : this is a set and so all the members are unique.

 

Input:
The first line of input contains a single integer T denoting the number of test cases.
Then T test cases follow. The first and only line of each test case consists of two space separated positive integers denoting n and d where n/d is an element of the set A. The fraction n/d will be greater than 1/10000.

Output:
Corresponding to each test case, in a new line, print the numerator and the denominator of the required irreducible fraction with a space in between.

Constraints:
1 ≤ T ≤ 100
1 ≤ n,d ≤ 10000

 

Example:
Input
3
1 8
2 53
7 64

Output
1249 9993
377 9991
1091 9975

** For More Input/Output Examples Use 'Expected Output' option **

Author: Hemang Sarkar


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.