Squares in Reactangle
Easy Accuracy: 16.26% Submissions: 852 Points: 2

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(modulo)corresponding to each test case in a separate line.

Constraints:
1 <= T <= 100 
1 <= A,B <= 1010

Example:
Input:
1
4 5
Output:
5

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

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.