#C1440. Maximum Product of Two Arrays

    ID: 44045 Type: Default 1000ms 256MiB

Maximum Product of Two Arrays

Maximum Product of Two Arrays

You are given two arrays A and B, each containing N integers. Your task is to compute the maximum product obtainable by selecting one element from A and one element from B.

Mathematically, if \(a_{\max} = \max\{A_i \mid 1 \le i \le N\}\) and \(b_{\max} = \max\{B_i \mid 1 \le i \le N\}\), then the answer is:

\(a_{\max} \times b_{\max}\)

Use this formula to design a program that reads input from stdin and writes the result to stdout for each test case.

inputFormat

The input is given via stdin and consists of multiple test cases. The first line contains a single integer T, the number of test cases. For each test case, the input is structured as follows:

  1. A line containing a single integer N, the number of elements in each array.
  2. A line with N space-separated integers representing the array A.
  3. A line with N space-separated integers representing the array B.

outputFormat

For each test case, output a single line containing the maximum product of one element from the first array and one element from the second array, computed as max(A) * max(B).

## sample
5
3
1 4 3
2 5 6
4
1 2 3 4
5 6 7 8
1
2
3
3
1 1 1
1 1 1
3
1000 999 998
1000 999 998
24

32 6 1 1000000

</p>