#K69207. Marathon Checkpoints
Marathon Checkpoints
Marathon Checkpoints
You are given a circular marathon track containing n checkpoints. A participant starts at the first checkpoint and may run for m minutes. In each minute, they move to the next checkpoint. However, since the track is circular, once they reach the last checkpoint, they return to the first one.
The task is to determine the maximum number of distinct checkpoints a participant can reach, including the starting point. Note that the result is given by \( \min(n, m+1) \), because the participant starts at the first checkpoint and can visit at most \( m+1 \) checkpoints in \( m \) minutes without repetition.
Use the input format described below and output the answer for each test case.
inputFormat
The first line contains an integer T denoting the number of test cases. Each of the following T lines contains two integers n and m separated by a space, where n is the number of checkpoints and m is the number of minutes available.
Example:
3 5 2 6 4 8 10
outputFormat
For each test case, output a single line containing the maximum number of distinct checkpoints a participant can reach.
Example Output:
3 5 8## sample
3
5 2
6 4
8 10
3
5
8
</p>