{"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\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":"","value":{"format":"HTML","content":"\u003cp\u003eYou are given two sequences $$$a_1, a_2, \\dots, a_n$$$ and $$$b_1, b_2, \\dots, b_n$$$. Each element of both sequences is either $$$0$$$, $$$1$$$ or $$$2$$$. The number of elements $$$0$$$, $$$1$$$, $$$2$$$ in the sequence $$$a$$$ is $$$x_1$$$, $$$y_1$$$, $$$z_1$$$ respectively, and the number of elements $$$0$$$, $$$1$$$, $$$2$$$ in the sequence $$$b$$$ is $$$x_2$$$, $$$y_2$$$, $$$z_2$$$ respectively.\u003c/p\u003e\u003cp\u003eYou can rearrange the elements in both sequences $$$a$$$ and $$$b$$$ however you like. After that, let\u0027s define a sequence $$$c$$$ as follows:\u003c/p\u003e\u003cp\u003e$$$c_i \u003d \\begin{cases} a_i b_i \u0026amp; \\mbox{if }a_i \u0026gt; b_i \\\\ 0 \u0026amp; \\mbox{if }a_i \u003d b_i \\\\ -a_i b_i \u0026amp; \\mbox{if }a_i \u0026lt; b_i \\end{cases}$$$\u003c/p\u003e\u003cp\u003eYou\u0027d like to make $$$\\sum_{i\u003d1}^n c_i$$$ (the sum of all elements of the sequence $$$c$$$) as large as possible. What is the maximum possible sum?\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\u003cp\u003eEach test case consists of two lines. The first line of each test case contains three integers $$$x_1$$$, $$$y_1$$$, $$$z_1$$$ ($$$0 \\le x_1, y_1, z_1 \\le 10^8$$$)\u0026nbsp;— the number of $$$0$$$-s, $$$1$$$-s and $$$2$$$-s in the sequence $$$a$$$.\u003c/p\u003e\u003cp\u003eThe second line of each test case also contains three integers $$$x_2$$$, $$$y_2$$$, $$$z_2$$$ ($$$0 \\le x_2, y_2, z_2 \\le 10^8$$$; $$$x_1 + y_1 + z_1 \u003d x_2 + y_2 + z_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":"Examples","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\u003cp\u003e$$$a \u003d \\{2, 0, 1, 1, 0, 2, 1\\}$$$\u003c/p\u003e\u003cp\u003e$$$b \u003d \\{1, 0, 1, 0, 2, 1, 0\\}$$$\u003c/p\u003e\u003cp\u003e$$$c \u003d \\{2, 0, 0, 0, 0, 2, 0\\}$$$\u003c/p\u003e\u003cp\u003eIn the second sample, one of the optimal solutions is:\u003c/p\u003e\u003cp\u003e$$$a \u003d \\{0, 2, 0, 0, 0\\}$$$\u003c/p\u003e\u003cp\u003e$$$b \u003d \\{1, 1, 0, 1, 0\\}$$$\u003c/p\u003e\u003cp\u003e$$$c \u003d \\{0, 2, 0, 0, 0\\}$$$\u003c/p\u003e\u003cp\u003eIn the third sample, the only possible solution is:\u003c/p\u003e\u003cp\u003e$$$a \u003d \\{2\\}$$$\u003c/p\u003e\u003cp\u003e$$$b \u003d \\{2\\}$$$\u003c/p\u003e\u003cp\u003e$$$c \u003d \\{0\\}$$$\u003c/p\u003e"}}]}