atcoder#ARC135E. [ARC135E] Sequence of Multiples
[ARC135E] Sequence of Multiples
Score : points
Problem Statement
You are given integers and . Assume that an integer sequence satisfies all of the conditions below.
- .
- For every (), is a multiple of .
- is strictly increasing. In other words, holds.
Find the minimum possible value of , modulo .
There are test cases, each of which should be solved.
Constraints
Input
Input is given from Standard Input from the following format:
Each case is in the following format:
Output
Print lines. The -th line should contain the answer for .
5
5 100
1 10
10 1
1000000000000000000 1
100 100
525
10
55
75433847
61074
Here is a sequence that minimizes for each of the first three test cases.
- The first test case: .
- The second test case: .
- The third test case: .