Charlie loves squares. So his friend Jack gives him a task to completely fill a rectangle of size AxB using squares of any sizes such that no two squares overlap. Now charlie wants to use minimum number of squares to complete this task. He needs help to count minimum number of squares to complete this task. The task is to find the minimum number of squares needed to fill the rectangle.

**Input:**

First line of input contains an integer T , denoting the number of test cases. Then T test cases follow. Each test case consists of a single line containing two space separated integers A and B.

**Output:**

Print the **Output % 1000000007**(mudulo)corresponding to each test case in a separate line.

**Constraints:**

1<=T<=100

1<=A,B<=10^10

**Example:**

**INPUT:**

1

4 5

**OUTPUT:**

5

**EXPLAINATION:**

Charlie can fill the rectangle of size 4x5 using one 4x4 square and four 1x1 squares.

Author: Mukesh Kumar 5

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.

vamsikrishna55 | 162 |

Vagesh Verma | 154 |

UrGuru | 133 |

chaolinyu | 98 |

Akhil varma | 97 |

abducodes | 650 |

harshtyagi36 | 304 |

highway_to_hell | 252 |

Akhil varma | 250 |

arpit_anshuman | 250 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.