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.

cs_abhi | 62 |

kya_bolti_public | 56 |

Shubhankar Sharma | 44 |

vermaankush14291 | 42 |

coderquill | 40 |

PiyushPandey4 | 856 |

john_wick | 757 |

ASWATHAMA | 565 |

akhyasharma01 | 547 |

UsfShilpa | 536 |

blackshadows | 5362 |

Ibrahim Nash | 5242 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4598 |

Login to report an issue on this page.