**Compilation/Execution Result:**

Given two integers ‘a’ and ‘m’, find modular multiplicative inverse of ‘a’ under modulo ‘m’.

Input: a = 3, m = 11

Output: 4

Since (4*3) mod 11 = 1, 4 is modulo inverse of 3

One might think, 15 also as a valid output as "(15*3) mod 11"

is also 1, but 15 is not in ring {0, 1, 2, ... 10}, so not valid.

**Note:** Print the smallest modular multiplicative inverse

**Input:**

First line consists of T test cases. Only line of every test case consists of 2 integers 'a' and 'm'.

**Output:**

Print the modular multiplicative inverse if exists else print -1.

**Constraints:**

1<=T<=100

1<=M<=100

1<=A<=M

**Example:
Input:**

2

3 11

10 17

4

12

Author: saksham seth

surbhi_7 | 148 |

Rajat Thakur 2 | 140 |

Ibrahim Nash | 120 |

aksh1996aksh | 117 |

Anupam Prakash 1 | 117 |

Ibrahim Nash | 634 |

ashrepos | 534 |

RealHorror | 395 |

shi143din | 385 |

shaktiman_shaktiman_shaktiman | 363 |

akhayrutdinov | 4052 |

sanjay05 | 3423 |

Quandray | 2446 |

Michael Riegger | 2228 |

Jasleen Kaur 2 | 2012 |