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.

sabka_din_aayega | 342 |

maggiiiii | 262 |

Savage_19 | 226 |

thanuvinu94 | 211 |

lost_found | 173 |

Bishnu Dev Panda | 803 |

sabka_din_aayega | 653 |

Anugrah_kumar | 562 |

okayboss | 561 |

maggiiiii | 545 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4925 |

Quandray | 4547 |

Login to report an issue on this page.