A guy has to reach his home and does not want to be late. He takes train to reach home. He has a mental illness, so he always switches train at every station.

**For eg**: If he starts with train A then at station 2 he will switch his train to train B and so on. Similarly, if he starts with train B then he will switch to train A at station 2 and so on. Please help him to find the minimum total time he would take to reach his home.

**Input:**

The first line of the input contains an integer **T** denoting the number of test cases. **T** test cases follow. Each testcase contains **three lines of input**. The first line contains a positive integer **N** - the number of tasks to be completed. The second line contains N space-separated positive integers representing the **time taken in seconds by train A** to reach next Stations. The third line contains N space-separated positive integers representing the **time taken in seconds by train B** to reach next Stations.

**Output:**

For each testcase, print the **minimum total time in seconds** to reach home.

**Constraints:**

1 <= T <= 100

1 <= N <= 10^{7}

1 <= Ai, Bi <= 10^{10}

**Example:
Input:**

1

3

2 1 2

3 2 1

5

**Explanation:
Testcase1:**

If he chose train A initially, then time to reach home will be : 2 + 2 + 2 = 6

If he Chose train B initially, then time to reach home will be : 3 + 1 + 1 = 5

5 is minimum hence the answer.

Author: saksham seth

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.

jhasaurabh312 | 138 |

Aaaaarohiiii | 136 |

Harsha_kunchala | 128 |

tushki | 124 |

RajaRajput | 117 |

ARUN_PUNDIR | 617 |

manishgupta8497 | 607 |

Abhimanyu_kumar | 559 |

KhyatiSoneji | 501 |

Aman___Jain | 496 |

blackshadows | 5335 |

Ibrahim Nash | 5223 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.