{"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\u003eA frog is currently at the point $$$0$$$ on a coordinate axis $$$Ox$$$. It jumps by the following algorithm: the first jump is $$$a$$$ units to the right, the second jump is $$$b$$$ units to the left, the third jump is $$$a$$$ units to the right, the fourth jump is $$$b$$$ units to the left, and so on.\u003c/p\u003e\u003cp\u003eFormally: \u003c/p\u003e\u003cul\u003e \u003cli\u003e if the frog has jumped an even number of times (before the current jump), it jumps from its current position $$$x$$$ to position $$$x+a$$$; \u003c/li\u003e\u003cli\u003e otherwise it jumps from its current position $$$x$$$ to position $$$x-b$$$. \u003c/li\u003e\u003c/ul\u003e\u003cp\u003eYour task is to calculate the position of the frog after $$$k$$$ jumps.\u003c/p\u003e\u003cp\u003eBut... One more thing. You are watching $$$t$$$ different frogs so you have to answer $$$t$$$ independent queries.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line of the input contains one integer $$$t$$$ ($$$1 \\le t \\le 1000$$$) — the number of queries.\u003c/p\u003e\u003cp\u003eEach of the next $$$t$$$ lines contain queries (one query per line).\u003c/p\u003e\u003cp\u003eThe query is described as three space-separated integers $$$a, b, k$$$ ($$$1 \\le a, b, k \\le 10^9$$$) — the lengths of two types of jumps and the number of jumps, respectively.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003ePrint $$$t$$$ integers. The $$$i$$$-th integer should be the answer for the $$$i$$$-th query.\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\u003e6\n5 2 3\n100 1 4\n1 10 5\n1000000000 1 6\n1 1 1000000000\n1 1 999999999\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e8\n198\n-17\n2999999997\n0\n1\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 query frog jumps $$$5$$$ to the right, $$$2$$$ to the left and $$$5$$$ to the right so the answer is $$$5 - 2 + 5 \u003d 8$$$.\u003c/p\u003e\u003cp\u003eIn the second query frog jumps $$$100$$$ to the right, $$$1$$$ to the left, $$$100$$$ to the right and $$$1$$$ to the left so the answer is $$$100 - 1 + 100 - 1 \u003d 198$$$.\u003c/p\u003e\u003cp\u003eIn the third query the answer is $$$1 - 10 + 1 - 10 + 1 \u003d -17$$$.\u003c/p\u003e\u003cp\u003eIn the fourth query the answer is $$$10^9 - 1 + 10^9 - 1 + 10^9 - 1 \u003d 2999999997$$$.\u003c/p\u003e\u003cp\u003eIn the fifth query all frog\u0027s jumps are neutralized by each other so the answer is $$$0$$$.\u003c/p\u003e\u003cp\u003eThe sixth query is the same as the fifth but without the last jump so the answer is $$$1$$$.\u003c/p\u003e"}}]}