Let's Play Curling
Time limit1sMemory limit512 MB
Given red and blue stone positions on a line, find a center point c that maximizes how many red stones are strictly closer to c than every blue stone, or report Impossible.
Problem
Curling is a sport in which players slide stones on a sheet of ice toward a target area. The team with the nearest stone to the center of the target area wins the game.
Two teams, Red and Blue, are competing on the number axis. After the game there are stones remaining on the axis, of them for the Red team and the other of them for the Blue. The -th stone of the Red team is positioned at and the -th stone of the Blue team is positioned at .
Let be the position of the center of the target area. From the description above we know that if there exists some such that and for all we have then Red wins the game. What's more, Red is declared to win points if the number of satisfying the constraint is exactly .
Given the positions of the stones for team Red and Blue, your task is to determine the position of the center of the target area so that Red wins the game and scores as much as possible. Note that can be any real number, not necessarily an integer.
Input
There are multiple test cases. The first line of the input contains an integer indicating the number of test cases. For each test case:
The first line contains two integers and () indicating the number of stones for Red and the number of stones for Blue.
The second line contains integers () indicating the positions of the stones for Red.
The third line contains integers () indicating the positions of the stones for Blue.
It's guaranteed that neither the sum of nor the sum of will exceed .
Output
For each test case output one line. If there exists some so that Red wins and scores as much as possible, output one integer indicating the maximum possible score of Red (NOT ). Otherwise output "Impossible" (without quotes) instead.
Hint
For the first sample test case we can assign so that the stones at position 2 and 3 for Red will score.
For the second sample test case we can assign so that the stones at position 5 and 7 for Red will score.