{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n disable: true\n };\n\u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eMonocarp had a sequence $$$a$$$ consisting of $$$n + m$$$ integers $$$a_1, a_2, \\dots, a_{n + m}$$$. He painted the elements into two colors, red and blue; $$$n$$$ elements were painted red, all other $$$m$$$ elements were painted blue.\u003c/p\u003e\n\u003cp\u003eAfter painting the elements, he has written two sequences $$$r_1, r_2, \\dots, r_n$$$ and $$$b_1, b_2, \\dots, b_m$$$. The sequence $$$r$$$ consisted of all red elements of $$$a$$$ \u003cspan class\u003d\"tex-font-style-bf\"\u003ein the order they appeared in $$$a$$$\u003c/span\u003e; similarly, the sequence $$$b$$$ consisted of all blue elements of $$$a$$$ \u003cspan class\u003d\"tex-font-style-bf\"\u003ein the order they appeared in $$$a$$$ as well\u003c/span\u003e.\u003c/p\u003e\n\u003cp\u003eUnfortunately, the original sequence was lost, and Monocarp only has the sequences $$$r$$$ and $$$b$$$. He wants to restore the original sequence. In case there are multiple ways to restore it, he wants to choose a way to restore that maximizes the value of\u003c/p\u003e\n\u003cp\u003e$$$$$$f(a) \u003d \\max(0, a_1, (a_1 + a_2), (a_1 + a_2 + a_3), \\dots, (a_1 + a_2 + a_3 + \\dots + a_{n + m}))$$$$$$\u003c/p\u003e\n\u003cp\u003eHelp Monocarp to calculate the maximum possible value of $$$f(a)$$$.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains one integer $$$t$$$ ($$$1 \\le t \\le 1000$$$) — the number of test cases. Then the test cases follow. Each test case consists of four lines.\u003c/p\u003e\n\u003cp\u003eThe first line of each test case contains one integer $$$n$$$ ($$$1 \\le n \\le 100$$$).\u003c/p\u003e\n\u003cp\u003eThe second line contains $$$n$$$ integers $$$r_1, r_2, \\dots, r_n$$$ ($$$-100 \\le r_i \\le 100$$$).\u003c/p\u003e\n\u003cp\u003eThe third line contains one integer $$$m$$$ ($$$1 \\le m \\le 100$$$).\u003c/p\u003e\n\u003cp\u003eThe fourth line contains $$$m$$$ integers $$$b_1, b_2, \\dots, b_m$$$ ($$$-100 \\le b_i \\le 100$$$).\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each test case, print one integer — the maximum possible value of $$$f(a)$$$.\u003c/p\u003e"}},{"title":"Sample 1","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e4\n4\n6 -5 7 -3\n3\n2 3 -4\n2\n1 1\n4\n10 -3 2 2\n5\n-1 -2 -3 -4 -5\n5\n-1 -2 -3 -4 -5\n1\n0\n1\n0\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e13\n13\n0\n0\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn the explanations for the sample test cases, red elements are marked as \u003cspan class\u003d\"tex-font-style-bf\"\u003ebold\u003c/span\u003e.\u003c/p\u003e\n\u003cp\u003eIn the first test case, one of the possible sequences $$$a$$$ is $$$[\\mathbf{6}, 2, \\mathbf{-5}, 3, \\mathbf{7}, \\mathbf{-3}, -4]$$$.\u003c/p\u003e\n\u003cp\u003eIn the second test case, one of the possible sequences $$$a$$$ is $$$[10, \\mathbf{1}, -3, \\mathbf{1}, 2, 2]$$$.\u003c/p\u003e\n\u003cp\u003eIn the third test case, one of the possible sequences $$$a$$$ is $$$[\\mathbf{-1}, -1, -2, -3, \\mathbf{-2}, -4, -5, \\mathbf{-3}, \\mathbf{-4}, \\mathbf{-5}]$$$.\u003c/p\u003e\n\u003cp\u003eIn the fourth test case, one of the possible sequences $$$a$$$ is $$$[0, \\mathbf{0}]$$$.\u003c/p\u003e"}}]}