atcoder#ARC150B. [ARC150B] Make Divisible
[ARC150B] Make Divisible
Score : points
Problem Statement
You are given positive integers and .
Find the minimum value of for non-negative integers and such that is a multiple of .
You have test cases to solve.
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Each case is in the following format:
Output
Print lines. The -th line should contain the answer for the -th test case.
5
11 23
8 16
4394 993298361
95392025 569922442
8399283 10293
2
0
65
2429708
8388990
For the first test case, if we let and , then will be a multiple of . Here, we have , and there is no way to make smaller, so the answer is .
For the second test case, if we let and , then will be a multiple of .