C. Lights Game
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Your friend is learning electronics, and he invented a new game he wants you to play.

There is a device with $$$n$$$ lightbulbs, disposed in a row. They are numbered from $$$1$$$ to $$$n$$$. The lightbulb $$$i$$$ has an integer $$$w_i$$$ written on it. Notice that $$$w_i$$$ might be negative. Initially, each lightbulb is on or off. In front of each light, except the first and the last lightbulb there is a button. In each step of the game, you may select a button and press it. If the lightbulb on the back is off, nothing will happen; however, if the lightbulb is on, it will turn off and the two neighboring lightbulbs will become on. There is no limit on the number of times you may press a button. When you decide to quit, your score is initially zero, but your friend will inspect all the lightbulbs, and if the $$$i$$$-th lightbulb is on, then he will add $$$w_i$$$ to the score.

What is the maximum possible score that can be obtained?

Input

The first line contains an integer $$$T$$$ ($$$1 \leq T \leq 2000$$$) corresponding to the number of testcases.

For each testcase, the first line contains an integer $$$n$$$ ($$$3 \leq n \leq 2000$$$), corresponding to the number of lightbulbs. The second line contains a string of size $$$n$$$, containing only the characters '$$$0$$$' or '$$$1$$$'. If the $$$i$$$-th character is $$$0$$$, then it means the $$$i$$$-th lightbulb from the left is off; otherwise, the $$$i$$$-th lightbulb from the left is on. The third line contains $$$n$$$ integers $$$w_1,w_2,\dots,w_n$$$ $$$(-10^9 \leq w_i \leq 10^9)$$$, that indicate the number written on the $$$i$$$-th lightbulb.

It is guaranteed that for all testcases the sum of $$$n$$$ is at most $$$2000$$$.

Output

The output should contain $$$T$$$ lines. The $$$i$$$-th line should contain the maximum possible score obtainable in the $$$i$$$-th testcase.

Example
Input
2
6
001100
1 -2 3 -4 5 -6
6
001100
1 -2 -3 4 5 -6
Output
9
8