{"trustable":true,"prependHtml":"\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 async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eCuber QQ has recently won a million dollars and bought a new car. He is now driving in the Infinite City and he doesn\u0027t want his car to stop, ever!\u003cbr\u003e\u003cbr\u003eThe Infinite City, looks like an infinite grid, with infinite streets built at all possible $x$\u0027s and $y$\u0027s when they are integers. The following picture, looks like part of this city. (The picture is downloaded from a webpage, which is certainly not describing the Infinite City.)\u003cbr\u003e\u003cbr\u003e\u003ccenter\u003e\u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/b5f1311f634d7333f138a0bf1d0b9a9b?v\u003d1714948537\"\u003e\u003c/center\u003e\u003cbr\u003e\u003cbr\u003eThere are traffic lights installed on every crossings. Just like what Chinese people usually do, the traffic lights only show signals for left and straight and you can always turn right regardless of the traffic light. The estimate time of waiting for a left turn is $a$, at all crossings; and the time of waiting for a straight is $b$.\u003cbr\u003e\u003cbr\u003eCuber QQ is now driving from $(0, -1)$ to $(0, 0)$, about to entering the crossing at $(0, 0)$. At a crossing, he can choose to go straight, turn left or turn right. He wishes to go to $(x, y)$, but here is a weird request: he wants to have the least estimated traffic light waiting time. In other words, he doesn\u0027t care whether he has to drive a long way, or he has to burn a lot of gas, all he wants is to wait as little as possible.\u003cbr\u003e\u003cbr\u003eNote that Cuber QQ doesn\u0027t have to wait for the traffic light at $(x, y)$; he also doesn\u0027t care from which direction he enters $(x, y)$.\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line of the input contains an integer $t$ ($1 \\le t \\le 100~000$).\u003cbr\u003e\u003cbr\u003eThen follows $t$ test cases, each containing $a$, $b$, $x$, $y$ ($1 \\le a, b \\le 10^9$, $-10^9 \\le x, y \\le 10^9$, $|x| + |y| \u0026gt; 0$), space separated. \u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, output one integer as the answer."}},{"title":"Sample","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\r\n9 1 0 2\r\n2 1 8 0\r\n2 3 3 3\r\n1 1 -1 -1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\n7\r\n6\r\n1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}