Different Rules
Contest: Codeforces Round 622 (Div. 2)
Difficulty rating: 1700
Tags: constructive algorithms, greedy, implementation, math

Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be $$$n$$$ participants, one of whom is Nikolay. Like any good olympiad, it consists of two rounds. Tired of the traditional rules, in which the participant who solved the largest number of problems wins, the organizers came up with different rules.

Suppose in the first round participant A took $$$x$$$-th place and in the second round — $$$y$$$-th place. Then the total score of the participant A is sum $$$x + y$$$. The overall place of the participant A is the number of participants (including A) having their total score less than or equal to the total score of A. Note, that some participants may end up having a common overall place. It is also important to note, that in both the first and the second round there were no two participants tying at a common place. In other words, for every $$$i$$$ from $$$1$$$ to $$$n$$$ exactly one participant took $$$i$$$-th place in first round and exactly one participant took $$$i$$$-th place in second round.

Right after the end of the Olympiad, Nikolay was informed that he got $$$x$$$-th place in first round and $$$y$$$-th place in the second round. Nikolay doesn't know the results of other participants, yet he wonders what is the minimum and maximum place he can take, if we consider the most favorable and unfavorable outcome for him. Please help Nikolay to find the answer to this question.

Input format:
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases to solve.

Each of the following $$$t$$$ lines contains integers $$$n$$$, $$$x$$$, $$$y$$$ ($$$1 \leq n \leq 10^9$$$, $$$1 \le x, y \le n$$$) — the number of participants in the olympiad, the place that Nikolay took in the first round and the place that Nikolay took in the second round.

Output format:
Print two integers — the minimum and maximum possible overall place Nikolay could take.

Constraints:
Time limit: 1.0 s
Memory limit: 256.0 MB

Note:
Explanation for the first example:

Suppose there were 5 participants A-E. Let's denote Nikolay as A. The the most favorable results for Nikolay could look as follows:

However, the results of the Olympiad could also look like this:

In the first case Nikolay would have taken first place, and in the second — third place.

Example input:
1
5 1 3

Example output:
1 3

Example input:
1
6 3 4

Example output:
2 6

Editorial:
Without loss of generality, assume that $$$x \leq y$$$. For convenience, we will number the participants from 1 to $$$n$$$ in the order of their places in the first round. Thus, the participant we are interested in is the participant $$$x$$$.
First we can prove the formula: $$$ \operatorname{MIN\_PLACE} = \max(1, \min(n, x + y - n + 1))$$$
1. First case: $$$x + y < n$$$. It can be shown that participant $$$x$$$ can achieve first place in the Olympics. In order to do this, the following example can be built:  $$$i$$$-th participant ($$$1 \leq i \leq x-1$$$) takes $$$(x+y+1-i)$$$-th place in the second round (sum — $$$x+y+1$$$) $$$x$$$-th participant takes $$$y$$$-th place in the second round (sum — $$$x+y$$$) $$$j$$$-th participant ($$$x+1 \leq j \leq n-y$$$) takes $$$(n+x+1-j)$$$-th place in the second round (sum — $$$n+x+1$$$) $$$(n-y+1)$$$-th participant takes $$$(y+1)$$$-th place in the second round (sum — $$$n+2$$$)  $$$t$$$-th participant ($$$n-y+2 \leq t \leq n$$$) takes $$$(n+1-t)$$$-th place in the second round (sum — $$$n+1$$$) The illustration below explains this example
2. $$$i$$$-th participant ($$$1 \leq i \leq x-1$$$) takes $$$(x+y+1-i)$$$-th place in the second round (sum — $$$x+y+1$$$)
3. $$$x$$$-th participant takes $$$y$$$-th place in the second round (sum — $$$x+y$$$)
4. $$$j$$$-th participant ($$$x+1 \leq j \leq n-y$$$) takes $$$(n+x+1-j)$$$-th place in the second round (sum — $$$n+x+1$$$)
5. $$$(n-y+1)$$$-th participant takes $$$(y+1)$$$-th place in the second round (sum — $$$n+2$$$)
6. $$$t$$$-th participant ($$$n-y+2 \leq t \leq n$$$) takes $$$(n+1-t)$$$-th place in the second round (sum — $$$n+1$$$)
7. Second case: $$$x + y \geq n+1;\; y \ne n$$$Consider the participant with the number $$$k$$$ ($$$k \leq x + y - n < x$$$). They will receive no more than $$$x+y-n+n = x + y$$$ in total (because $$$n$$$ is the maximum place in the second round they can take), that is guaranteed to overtake the main character. Thus we can't achieve any place better than $$$x+y-n+1$$$. For this assessment, an example below is given: $$$i$$$-th participant $$$(1 \leq i \leq x+y-n)$$$ takes $$$i$$$-th place in the second round (sum — $$$2i < x + y$$$) $$$j$$$-th participant $$$(x+y-n+1 \leq j \leq x-1)$$$ takes $$$(x+y+1-j)$$$-th place in the second round (sum — $$$x+y+1$$$) $$$x$$$-th participant takes the y-th place in the second round (sum — $$$x+y$$$) $$$(x+1)$$$-th participant takes $$$(y+1)$$$-th place in the second round (sum — $$$x+y+2$$$) $$$t$$$-th participant $$$(x+2 \leq t \leq n)$$$ takes $$$(x+y+1-t)$$$-th place in the second round (sum — $$$x+y+1$$$) The illustration below explains this example
8. $$$i$$$-th participant $$$(1 \leq i \leq x+y-n)$$$ takes $$$i$$$-th place in the second round (sum — $$$2i < x + y$$$)
9. $$$j$$$-th participant $$$(x+y-n+1 \leq j \leq x-1)$$$ takes $$$(x+y+1-j)$$$-th place in the second round (sum — $$$x+y+1$$$)
10. $$$x$$$-th participant takes the y-th place in the second round (sum — $$$x+y$$$)
11. $$$(x+1)$$$-th participant takes $$$(y+1)$$$-th place in the second round (sum — $$$x+y+2$$$)
12. $$$t$$$-th participant $$$(x+2 \leq t \leq n)$$$ takes $$$(x+y+1-t)$$$-th place in the second round (sum — $$$x+y+1$$$)
13. Third case: $$$x + y \geq n+1$$$; $$$y = n$$$Then the participant with the number $$$k$$$ ($$$k \leq x + y - n + 1 = x + 1$$$) will receive no more than $$$x+y-n+1+n-1 = x + y$$$ in total, that is guaranteed to overtake the main character. That is, we can't take places better than $$$x+y-n+1$$$. For this assessment, we give an example below: Participant $$$i < x$$$ takes $$$x$$$-th place, overtaking $$$x+y$$$ Participant $$$x + 1$$$ takes $$$(n-1)$$$-th place, overtaking $$$x+y$$$ Participant $$$j$$$ ($$$x + 2 \leq j \leq n$$$) takes $$$(x+y+1-j)$$$-th placeA separate case: $$$x = y = n$$$, then the outcome is obvious
14. Participant $$$i < x$$$ takes $$$x$$$-th place, overtaking $$$x+y$$$
15. Participant $$$x + 1$$$ takes $$$(n-1)$$$-th place, overtaking $$$x+y$$$
16. Participant $$$j$$$ ($$$x + 2 \leq j \leq n$$$) takes $$$(x+y+1-j)$$$-th place
The formula for the minimum place is proved. The formula for the maximum place will be proven in the same way:
We prove the formula: $$$ \operatorname{MAX\_PLACE} = \min(n, x + y-1)$$$
1. First case: $$$x + y \geq n+1$$$. Then we can give an example in which we will take the last place: $$$i$$$-th participant ($$$1 \leq i \leq x+y-n-1$$$) takes $$$(y+x-n-i)$$$-th place in the second round (sum — $$$y + x-n$$$) $$$j$$$-th participant ($$$x+y-n-1 \leq j \leq n$$$) takes $$$(x+y-j)$$$-th place in the second round (sum — $$$y + x$$$)
2. $$$i$$$-th participant ($$$1 \leq i \leq x+y-n-1$$$) takes $$$(y+x-n-i)$$$-th place in the second round (sum — $$$y + x-n$$$)
3. $$$j$$$-th participant ($$$x+y-n-1 \leq j \leq n$$$) takes $$$(x+y-j)$$$-th place in the second round (sum — $$$y + x$$$)
4. Second case: $$$x + y \leq n$$$ Consider a participant with the number $$$k$$$ ($$$x+y \leq k$$$). They are guaranteed to be overtaken by $$$x+y$$$ (main character) So the main character can not take any place worse than $$$x+y-1$$$: $$$i$$$-th participant ($$$1 \leq i \leq x+y-1$$$) takes ($$$y+x-i$$$)-th place in the second round (sum — $$$y + x-n$$$) $$$j$$$-th participant ($$$x+y-1 \leq j \leq n$$$) takes ($$$x+y+n-j$$$)-th place in the second round (sum — $$$y + x$$$)
5. $$$i$$$-th participant ($$$1 \leq i \leq x+y-1$$$) takes ($$$y+x-i$$$)-th place in the second round (sum — $$$y + x-n$$$)
6. $$$j$$$-th participant ($$$x+y-1 \leq j \leq n$$$) takes ($$$x+y+n-j$$$)-th place in the second round (sum — $$$y + x$$$)
Thus, the problem was reduced to the problem of output of two numbers – $$$\left< \max(1, \min(n, x + y - n + 1)),\;\;\min(n, x + y-1)\right>$$$