GCD and Fibonacci Numbers
Easy Accuracy: 14.84% Submissions: 1531 Points: 2

You will be given two positive numbers M and N. Your task is to print the greatest common divisor of Fib(M) and Fib(N) where Fib(x) means the xth Fibonacci numbers defined as:

Fib(0) = 0

Fib(1) = 1

for n > 1, Fib(n) = Fib(n-1) + Fib(n-2)

Input:
The first line of input contains a single integer T denoting the number of test cases. Then T test cases follow. Each test case consists of exactly one line. This line consists of two space separated positive integers N and M.

Output:
Corresponding to each test case, in a new line, print the value of gcd( Fib(M), Fib(N) ) modulo 100.

Constraints:
1 ≤ T ≤ 1000
1 ≤ M, N ≤ 1000

Example:
Input:
2
3 6
7 8

Output:
2
1

Explanation:
Fib(3) = 2 and Fib(6) = 8
GCD(2,8)%100 = 2

Fib(7) = 13 and Fib(8) = 21
GCD(13,21)%100 = 1

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.

Output Window