#C3259. Equal Modulo Adjustment
Equal Modulo Adjustment
Equal Modulo Adjustment
You are given three integers a, b, and m. Your task is to find the smallest non-negative integer x such that
\( (a + x) \mod m = (b + x) \mod m \)
This is equivalent to finding the difference between b and a in modulo m arithmetic. The solution can be computed as \( x = (b - a) \mod m \). If the result of \( (b - a) \mod m \) is negative, adjust it to be non-negative.
The input consists of multiple test cases, and your program should output the result for each test case on a separate line.
inputFormat
The first line contains an integer T indicating the number of test cases. Each of the following T lines contains three space-separated integers: a, b, and m.
outputFormat
For each test case, output a single line containing the smallest non-negative integer x such that \( (a + x) \mod m = (b + x) \mod m \).
## sample3
10 12 5
6 8 4
15 20 10
2
2
5
</p>