#P7978. Unfair contest
Unfair contest
Unfair contest
Problem Description
I'm going to give my scores fairly. It's just that some contestant deserves a fairer score... gispzjz and zyb are participating in a contest, with referees awarding scores(according to their performance, usually) to them. For each contestant, each referee should name an integer in the interval as the score, and the final score of the contestant is the sum over all scores he gets after eliminating highest scores and lowest scores. As one of the referees, you had a bet on gispzjz, so you want him to win this contest, but you also don't want this to look too obvious. Suppose you know the other referees have awarded scores to gispzjz and to zyb. You need to give out your scores and so that the final score of gispzjz is strictly higher than zyb. If that's achievable, you also need to minimize , conditioned on the final score of gispzjz is strictly higher than zyb.
Input
The first line contains a number , denoting the number of test cases. The first line of each test case contains four integers $n,s,t,h(1\leq n\leq 10^5, 0\leq s,t \leq n-1, 1\leq h \leq 10^9)$, denoting the number of referees, the number of highest and lowest scores that need to be eliminated, and the scoring range for referees, respectively. It is guaranteed that . Then one line containing integers follow, denoting the scores already awarded to gispzjz. Then another line containing integers follow, denoting the scores already awarded to zyb. It is guaranteed that over all test cases.
Output
For each test case, if it's possible to make gispzjz's score strictly higher than zyb, then output the minimized in one line, otherwise output "IMPOSSIBLE"(without quotes) in one line.
Sample Input
3
3 1 1 4
1 3
2 4
4 1 1 9
4 4 5
4 5 5
4 1 1 9
4 5 5
4 4 5
Sample Output
1
IMPOSSIBLE
-4
Source
2021“MINIEYE杯”中国大学生算法设计超级联赛(9)