{"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\u003cscript\u003e window.katexOptions \u003d { disable: true }; \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\u003c/script\u003e","sections":[{"title":"Description","value":{"format":"HTML","content":"\u003cp\u003eGod has given \"TwoPointO\" two streams $$$a_1, a_2, \\dots, a_n$$$ and $$$b_1, b_2, \\dots, b_n$$$. Each element of both streams is either $$$0$$$, $$$1$$$ or $$$2$$$. The number of elements $$$0$$$, $$$1$$$, $$$2$$$ in the sequence $$$a$$$ is $$$i_1$$$, $$$j_1$$$, $$$k_1$$$ respectively, and the number of elements $$$0$$$, $$$1$$$, $$$2$$$ in the sequence $$$b$$$ is $$$i_2$$$, $$$j_2$$$, $$$k_2$$$ respectively.\u003c/p\u003e\n\u003cp\u003e\"TwoPointO\" can rearrange the elements in both streams $$$a$$$ and $$$b$$$ as he wants and then he merges both streams to form a new sequence $$$c$$$ such that:\u003c/p\u003e\n\u003cp\u003e$$$c_i \u003d \\begin{cases} a_i b_i \u0026amp; {if }(a_i \u0026gt; b_i) \\\\ 0 \u0026amp; {if }(a_i \u003d b_i )\\\\ -a_i b_i \u0026amp; {if }(a_i \u0026lt; b_i) \\end{cases}$$$\u003c/p\u003e\n\u003cp\u003eHe\u0027d like to make $$$\\sum_{i\u003d1}^n c_i$$$ (the sum of all elements of the sequence $$$c$$$) as large as possible.\u003c/p\u003e\n\u003c/n\u003e\n\u003cp\u003eHelp $$$\"TwoPointO\"$$$ to find the maximum sum of sequence c.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains one integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$)\u0026nbsp;— the number of test cases.\u003c/p\u003e\n\u003cp\u003eEach test case consists of two lines. The first line of each test case contains three integers $$$i_1$$$, $$$j_1$$$, $$$k_1$$$ ($$$0 \\le i_1, j_1, k_1 \\le 10^8$$$)\u0026nbsp;— the number of $$$0$$$-s, $$$1$$$-s and $$$2$$$-s in the sequence $$$a$$$.\u003c/p\u003e\n\u003cp\u003eThe second line of each test case also contains three integers $$$i_2$$$, $$$j_2$$$, $$$k_2$$$ ($$$0 \\le i_2, j_2, k_2 \\le 10^8$$$; $$$i_1 + j_1 + k_1 \u003d i_2 + j_2 + k_2 \u0026gt; 0$$$)\u0026nbsp;— the number of $$$0$$$-s, $$$1$$$-s and $$$2$$$-s in the sequence $$$b$$$.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each test case, print the maximum possible sum of the sequence $$$c$$$.\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\u003e3\n2 3 2\n3 3 1\n4 0 1\n2 3 0\n0 0 1\n0 0 1\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4\n2\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 first sample, one of the optimal solutions is:\u003c/p\u003e\n\u003cp\u003e$$$a \u003d \\{2, 0, 1, 1, 0, 2, 1\\}$$$\u003c/p\u003e\n\u003cp\u003e$$$b \u003d \\{1, 0, 1, 0, 2, 1, 0\\}$$$\u003c/p\u003e\n\u003cp\u003e$$$c \u003d \\{2, 0, 0, 0, 0, 2, 0\\}$$$\u003c/p\u003e\n\u003cp\u003eIn the second sample, one of the optimal solutions is:\u003c/p\u003e\n\u003cp\u003e$$$a \u003d \\{0, 2, 0, 0, 0\\}$$$\u003c/p\u003e\n\u003cp\u003e$$$b \u003d \\{1, 1, 0, 1, 0\\}$$$\u003c/p\u003e\n\u003cp\u003e$$$c \u003d \\{0, 2, 0, 0, 0\\}$$$\u003c/p\u003e\n\u003cp\u003eIn the third sample, the only possible solution is:\u003c/p\u003e\n\u003cp\u003e$$$a \u003d \\{2\\}$$$\u003c/p\u003e\n\u003cp\u003e$$$b \u003d \\{2\\}$$$\u003c/p\u003e\n\u003cp\u003e$$$c \u003d \\{0\\}$$$\u003c/p\u003e"}}]}