Given a integer **n**. We have **n*n** values of a 2-d array, and **n** values of 1-d array. Task is to find the sum of the diagonal values of the 2-d array and the max element of the 1-d array and print them with space in between.

**Input:** First line of input contains a single integer T which denotes the number of test cases. T test cases follows, first line of each test case contains a integer n. Second line consists of n*n spaced integers. Third and last line consists of n spaced integers.

**Output:** Print the sum of the diagonal elements and the maximum number of the 1-d array with spaces in between.

**Constraints:**

1<=T<=100

1<= n <=100

1<=element<=10^{3}

**Example:**

**Input:**

1

3

1 2 3 4 5 6 7 8 9

3 6 9

**Output:**

15 9

Author: saksham0751

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.

agness | 122 |

aman1931998 | 102 |

Survivor | 100 |

uchitnitk | 96 |

lonecoder | 95 |

KshatriyaYash | 1066 |

nikhil_sojan | 1032 |

lonecoder | 1030 |

mazumderrohit8 | 899 |

SumitSingh27 | 832 |

blackshadows | 5327 |

Ibrahim Nash | 5215 |

akhayrutdinov | 5111 |

mb1973 | 4492 |

Quandray | 4444 |

Login to report an issue on this page.