
ZOJ Problem Set  3819
Bob is a freshman in Marjar University. He is clever and diligent. However, he is not good at math, especially in Mathematical Analysis. After a midterm exam, Bob was anxious about his grade. He went to the professor asking about the result of the exam. The professor said:
Now, you are given the scores of all students in the two classes, except for the Bob's. Please calculate the possible range of Bob's score. All scores shall be integers within [0, 100]. InputThere are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case: The first line contains two integers N (2 <= N <= 50) and M (1 <= M <= 50) indicating the number of students in Bob's class and the number of students in the other class respectively. The next line contains N  1 integers A_{1}, A_{2}, .., A_{N1} representing the scores of other students in Bob's class. The last line contains M integers B_{1}, B_{2}, .., B_{M} representing the scores of students in the other class. OutputFor each test case, output two integers representing the minimal possible score and the maximal possible score of Bob. It is guaranteed that the solution always exists. Sample Input2 4 3 5 5 5 4 4 3 6 5 5 5 4 5 3 1 3 2 2 1 Sample Output4 4 2 4 Author: JIANG, Kai Source: The 2014 ACMICPC Asia Mudanjiang Regional Contest 