{"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\u003eBaoBao and DreamGrid are playing a card game. Each player has $$$n$$$ cards in the beginning and there are three types of cards: rock, paper, and scissors.\u003c/p\u003e\u003cp\u003eThe game consists of $$$n$$$ rounds. In each round, BaoBao will first play one of his remaining cards (this card is shown to both players). After that, DreamGrid can choose one of his remaining cards and play it (also shown to both players). The score of this round is calculated by referring to the following table:\u003c/p\u003e\u003ccenter\u003e \u003ctable class\u003d\"tex-tabular\"\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd class\u003d\"tex-tabular-border-left tex-tabular-text-align-center tex-tabular-border-right tex-tabular-border-top tex-tabular-border-bottom\"\u003eDreamGrid $$$\\downarrow$$$ $$$\\,\\,\\,\\,$$$ BaoBao $$$\\rightarrow$$$\u003c/td\u003e\u003ctd class\u003d\"tex-tabular-border-left tex-tabular-text-align-center tex-tabular-border-right tex-tabular-border-top tex-tabular-border-bottom\"\u003e\u003cspan class\u003d\"tex-font-style-bf\"\u003eRock\u003c/span\u003e\u003c/td\u003e\u003ctd class\u003d\"tex-tabular-border-left tex-tabular-text-align-center tex-tabular-border-right tex-tabular-border-top tex-tabular-border-bottom\"\u003e\u003cspan class\u003d\"tex-font-style-bf\"\u003ePaper\u003c/span\u003e\u003c/td\u003e\u003ctd class\u003d\"tex-tabular-border-left tex-tabular-text-align-center tex-tabular-border-right tex-tabular-border-top tex-tabular-border-bottom\"\u003e\u003cspan class\u003d\"tex-font-style-bf\"\u003eScissors\u003c/span\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"tex-tabular-border-left tex-tabular-text-align-center tex-tabular-border-right tex-tabular-border-top tex-tabular-border-bottom\"\u003e\u003cspan class\u003d\"tex-font-style-bf\"\u003eRock\u003c/span\u003e\u003c/td\u003e\u003ctd class\u003d\"tex-tabular-border-left tex-tabular-text-align-center tex-tabular-border-right tex-tabular-border-top tex-tabular-border-bottom\"\u003e0\u003c/td\u003e\u003ctd class\u003d\"tex-tabular-border-left tex-tabular-text-align-center tex-tabular-border-right tex-tabular-border-top tex-tabular-border-bottom\"\u003e-1\u003c/td\u003e\u003ctd class\u003d\"tex-tabular-border-left tex-tabular-text-align-center tex-tabular-border-right tex-tabular-border-top tex-tabular-border-bottom\"\u003e1\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"tex-tabular-border-left tex-tabular-text-align-center tex-tabular-border-right tex-tabular-border-top tex-tabular-border-bottom\"\u003e\u003cspan class\u003d\"tex-font-style-bf\"\u003ePaper\u003c/span\u003e\u003c/td\u003e\u003ctd class\u003d\"tex-tabular-border-left tex-tabular-text-align-center tex-tabular-border-right tex-tabular-border-top tex-tabular-border-bottom\"\u003e1\u003c/td\u003e\u003ctd class\u003d\"tex-tabular-border-left tex-tabular-text-align-center tex-tabular-border-right tex-tabular-border-top tex-tabular-border-bottom\"\u003e0\u003c/td\u003e\u003ctd class\u003d\"tex-tabular-border-left tex-tabular-text-align-center tex-tabular-border-right tex-tabular-border-top tex-tabular-border-bottom\"\u003e-1\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"tex-tabular-border-left tex-tabular-text-align-center tex-tabular-border-right tex-tabular-border-top tex-tabular-border-bottom\"\u003e\u003cspan class\u003d\"tex-font-style-bf\"\u003eScissors\u003c/span\u003e\u003c/td\u003e\u003ctd class\u003d\"tex-tabular-border-left tex-tabular-text-align-center tex-tabular-border-right tex-tabular-border-top tex-tabular-border-bottom\"\u003e-1\u003c/td\u003e\u003ctd class\u003d\"tex-tabular-border-left tex-tabular-text-align-center tex-tabular-border-right tex-tabular-border-top tex-tabular-border-bottom\"\u003e1\u003c/td\u003e\u003ctd class\u003d\"tex-tabular-border-left tex-tabular-text-align-center tex-tabular-border-right tex-tabular-border-top tex-tabular-border-bottom\"\u003e0\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e \u003c/center\u003e\u003cp\u003eAfter the round, the two played cards are removed from the game. The score of the whole game is the sum of the score of each round.\u003c/p\u003e\u003cp\u003eBaoBao aims at minimizing the score of the whole game, while DreamGrid aims at maximizing it. Both players know the number of cards of each type his opponent and himself holds in the beginning. What\u0027s the final score of the game given that both of them take the best strategy?\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThere are multiple test cases. The first line of the input contains an integer $$$T$$$ ($$$1 \\le T \\le 10^3$$$) indicating the number of test cases. For each test case:\u003c/p\u003e\u003cp\u003eThe first line contains three integers $$$b_r$$$, $$$b_p$$$ and $$$b_s$$$ ($$$0 \\le b_r, b_p, b_s \\le 10^9$$$), indicating the number of rock, paper and scissors cards BaoBao has.\u003c/p\u003e\u003cp\u003eThe second line contains three integers $$$d_r$$$, $$$d_p$$$ and $$$d_s$$$ ($$$0 \\le d_r, d_p, d_s \\le 10^9$$$), indicating the number of rock, paper and scissors cards DreamGrid has.\u003c/p\u003e\u003cp\u003eIt\u0027s guaranteed that $$$b_r + b_p + b_s \u003d d_r + d_p + d_s$$$.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each test case output one line containing one integer indicating the final score of game.\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\u003e4\n4 4 2\n10 0 0\n0 10 0\n2 4 4\n1 2 3\n3 2 1\n10 10 10\n10 10 10\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e-2\n2\n5\n30\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}