Under construction

Still being built. Things may change

Stickers

Interview

Time limit1sMemory limit256 MB

Summary
Pick stickers from a 2 by n grid with no two sharing an edge to maximize the total score.
Level

Medium4 of 10

Topics
Dynamic programming, Array
Solved
No attempts yet

Problem

Sanggeun's younger sister Sangnyang bought 2n2n stickers at a stationery store. They come stuck together in a grid of 2 rows and nn columns, and she wants to decorate her desk with them.

The stickers are made badly. When one is peeled off, every sticker that shares an edge with it tears and can no longer be used, so the stickers above, below, to the left, and to the right of the peeled one are lost.

Since she cannot use all of them, Sangnyang scores each sticker and peels off the set with the largest total score. Write a program that finds the maximum total score of a set chosen from the 2n2n stickers in which no two chosen stickers share an edge.

When the two highest scores sit on stickers that share an edge, those two cannot both be peeled off. The best set then has to use lower-scoring stickers that do not touch each other.

Input

The first line contains the number of test cases TT. The first line of each test case contains nn (1≤n≤1000001 \le n \le 100000). The next two lines each contain nn integers, where each integer is the score of the sticker at that position. Two consecutive integers are separated by a single space. Every score is an integer between 00 and 100100, inclusive.

Output

For each test case, print on its own line the maximum total score of a set of stickers in which no two share an edge.

Examples1

  1. Example 1

    Input
    2
    5
    50 10 100 20 40
    30 50 70 10 60
    7
    10 30 10 50 100 20 40
    20 40 30 50 60 20 80
    
    Expected output
    260
    290