Expression Again

You are given an algebraic expression of the form (x1 +x2 +x3 +...+xn)∗(y1 +y2 +...+ym) and (n + m) integers. You have to find the maximum and minimum value of the expression using the given integers. For example if you are given (x1 + x2) ∗ (y1 + y2) and you are given 1, 2, 3 and 4. Then maximum value is (1 + 4) ∗ (2 + 3) = 25 where as minimum value is (4 + 3) ∗ (2 + 1) = 21. Input Each input set starts with two positive integers N , M (< 51). Next line follows (N + M ) integers which are in the range of −50 to 50. Input is terminated by end of file. There will be atmost 110 testcases. Output Output is one line for each case, maximum value followed by minimum value. Sample Input 22 1234 31 1234 22 2222 Sample Output 25 21 24 9 16 16