Given two arrays of A and B respectively of sizes N_{1} and N_{2}, the task is to calculate the product of maximum element of first array and minimum element of second array.

**Input:**

The first line of the input contains a single integer **T**, denoting the number of test cases. Then T test case follows. Each testcase contains 4 lines. First line contains size of the first array N_{1}, next line contains elements of the first array separated by spaces. Third line contains size of the second array N_{2} and next line contains elements of the second array separated by spaces.

**Output:**

For each testcase, output the product of the max element of the first array and the minimum element of the second array.

**Constraints:**

1 <= T <= 100

1 <= N_{1}, N_{2 }<= 10^{6}

-10^{8} <= A_{i} <= 10^{8}

**Example:
Input:**

2

6

5 7 9 3 6 2

6

1 2 6 -1 0 9

6

1 4 2 3 10 2

6

4 2 6 5 2 9

**Output:**

-9

20

**Explanation:**

**Testcase 1:** The first array is 5 7 9 3 6 2. The max element among these elements is 9. The second array is 1 2 6 -1 0 9. The min element among these elements is -1. The product of 9 and -1 is 9*-1=-9.

Author: Soul_xhacker

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

manishgupta8497 | 607 |

ARUN_PUNDIR | 309 |

vvggfggcg | 300 |

KhyatiSoneji | 272 |

greatpan | 241 |

manishgupta8497 | 607 |

ARUN_PUNDIR | 567 |

KhyatiSoneji | 501 |

Abhimanyu_kumar | 457 |

vvggfggcg | 453 |

blackshadows | 5333 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.