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

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.

parass321 | 46 |

YogeshSharma7479 | 46 |

ayushwagdre1 | 44 |

yashranjan74 | 42 |

geekscoder | 41 |

Pulkit__Sharma__ | 806 |

Anirban166 | 682 |

Found_me | 636 |

abducodes | 607 |

Sathvik Avasarala | 526 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4559 |

Login to report an issue on this page.