Mathforces

5

2 votes
Problem

You are given two integers A and BPrint the sum of numbers that cannot be formed using any combination of A and B . If the sum is infinite print 1. Since the answer can be large, print the sum modulo 109+9.

A combination of A and B can be represented as an integer C that is denoted as xA+yB where x and y are whole numbers.

 

INPUT FORMAT:

The first line contains an integer T, denoting the number of test cases. Each of the next T lines contains two space separated integers A and B.

 

OUTPUT FORMAT:

For each test case print the answer in a new line.

 

CONSTRAINTS:

1T105

1A,B109

B=A+1

 

Time Limit: 2
Memory Limit: 256
Source Limit:
Editor Image

?