#C718. Find the Last Badge
Find the Last Badge
Find the Last Badge
You are given two positive integers N and B, where N represents the number of coders and B represents the total number of badges available. The badges are numbered from 1 to B and are assigned to coders sequentially in a cyclic fashion. In other words, the assignment is done in a repeating cycle over the badge numbers. The task is to determine the badge number that the N-th coder will receive.
The assignment process can be described mathematically as follows: if we denote the result as R, then
\( R = N \mod B \)
Note that if \( N \mod B = 0 \), then the badge number assigned is B rather than 0.
This is a straightforward problem that tests basic understanding of modular arithmetic and cyclic assignments.
inputFormat
The input is read from stdin and has the following format:
- The first line contains an integer T representing the number of test cases.
- Each of the following T lines contains two space-separated integers N and B.
Constraints: All integers are positive.
outputFormat
For each test case, output the badge number that the N-th coder receives. Each result should be printed on a new line to stdout.
## sample2
5 8
10 3
5
1
</p>