{"trustable":false,"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\u003e$$$Hao$$$ 有一个由 n+m 个整数 $$$a_1,a_2,\\dots,a_{n+m}$$$ 组成的序列 $$$a$$$。他将元素涂成两种颜色,红色和蓝色; n 个元素被涂成红色,所有其他 m 个元素被涂成蓝色。绘制元素后,他编写了两个序列 $$$r_1, r_2, \\dots, r_n$$$和 $$$b_1, b_2, \\dots, b_m$$$。序列 $$$ r$$$ 由 $$$a$$$ 的所有红色元素按照它们出现在 $$$a$$$ 中的顺序组成;类似地,序列 $$$ b$$$ 由 $$$ a$$$ 的所有蓝色元素组成,也按照它们在 $$$a $$$ 中出现的顺序组成。不幸的是,原始序列丢失了,$$$Hao$$$ 只有序列 $$$r$$$ 和 $$$b$$$。他要恢复原来的顺序。如果有多种恢复方式,他想选择一种恢复方式,使其最大化:\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\u003e 帮助 $$$Hao$$$ 计算$$$ f(a) $$$的最大可能值。\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003e第一行包含一个整数 t (1≤t≤1000) — 测试用例的数量。\u003c/p\u003e\n\u003cp\u003e然后是测试用例。每个测试用例由四行组成。每个测试用例的第一行包含一个整数 n (1≤n≤100)。\u003c/p\u003e\n\u003cp\u003e第二行包含 $$$n$$$ 个整数 $$$r_1, r_2, \\dots, r_n$$$ ($$$-100 \\le r_i \\le 100$$$).\u003c/p\u003e\n\u003cp\u003e第三行包含一个整数 m(1≤m≤100)。\u003c/p\u003e\n\u003cp\u003e第四行包含 $$$m$$$ 个整数 $$$b_1, b_2, \\dots, b_m$$$ ($$$-100 \\le b_i \\le 100$$$).\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003e对于每个测试用例,打印一个整数——$$$f(a) $$$的最大可能值。\u003c/p\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"4\u003cbr\u003e\n4\u003cbr\u003e\n6 -5 7 -3\u003cbr\u003e\n3\u003cbr\u003e\n2 3 -4\u003cbr\u003e\n2\u003cbr\u003e\n1 1\u003cbr\u003e\n4\u003cbr\u003e\n10 -3 2 2\u003cbr\u003e\n5\u003cbr\u003e\n-1 -2 -3 -4 -5\u003cbr\u003e\n5\u003cbr\u003e\n-1 -2 -3 -4 -5\u003cbr\u003e\n1\u003cbr\u003e\n0\u003cbr\u003e\n1\u003cbr\u003e\n0\u003cbr\u003e\n"}},{"title":"Sample Output","value":{"format":"HTML","content":"13\u003cbr\u003e\n13\u003cbr\u003e\n0\u003cbr\u003e\n0\u003cbr\u003e\n"}},{"title":"Tip","value":{"format":"HTML","content":"\u003cp\u003e在示例测试用例的说明中,红色元素标记为 \u003cspan class\u003d\"tex-font-style-bf\"\u003e粗体\u003c/span\u003e。\u003c/p\u003e\n\u003cp\u003e在第一个测试用例中,一个可能的序列 $$$a$$$ 是 $$$[\\mathbf{6}, 2, \\mathbf{-5}, 3, \\mathbf{7}, \\mathbf{-3}, -4]$$$.\u003c/p\u003e\n\u003cp\u003e在第二个测试用例中,一个可能的序列 $$$a$$$ 是 $$$[10, \\mathbf{1}, -3, \\mathbf{1}, 2, 2]$$$.\u003c/p\u003e\n\u003cp\u003e在第三个测试用例中,一个可能的序列 $$$a$$$ 是 $$$[\\mathbf{-1}, -1, -2, -3, \\mathbf{-2}, -4, -5, \\mathbf{-3}, \\mathbf{-4}, \\mathbf{-5}]$$$.\u003c/p\u003e\n\u003cp\u003e在第四个测试用例中,一个可能的序列 $$$a$$$ 是 $$$[0, \\mathbf{0}]$$$.\u003c/p\u003e"}}]}