A 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.

Formally:   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$;  otherwise it jumps from its current position $x$ to position $x-b$. 

Your task is to calculate the position of the frog after $k$ jumps.

But... One more thing. You are watching $t$ different frogs so you have to answer $t$ independent queries.


-----Input-----

The first line of the input contains one integer $t$ ($1 \le t \le 1000$) — the number of queries.

Each of the next $t$ lines contain queries (one query per line).

The 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.


-----Output-----

Print $t$ integers. The $i$-th integer should be the answer for the $i$-th query.


-----Example-----
Input
6
5 2 3
100 1 4
1 10 5
1000000000 1 6
1 1 1000000000
1 1 999999999

Output
8
198
-17
2999999997
0
1



-----Note-----

In 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 = 8$.

In 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 = 198$.

In the third query the answer is $1 - 10 + 1 - 10 + 1 = -17$.

In the fourth query the answer is $10^9 - 1 + 10^9 - 1 + 10^9 - 1 = 2999999997$.

In the fifth query all frog's jumps are neutralized by each other so the answer is $0$.

The sixth query is the same as the fifth but without the last jump so the answer is $1$.

Source: codeforces | Difficulty: EASY
Tags: Mathematics


Solutions:
n = int(input())
I = []
for i in range(n):
	k = [int(i) for i in input().split()]
	I.append(k)

def output(a, b, n):
	if n % 2 != 0:
		x = (n // 2 + 1) * a - n // 2 * b
	else:
		x = n // 2 * a - n // 2 * b
	return x
for i in range(n):
	print(output(I[i][0], I[i][1], I[i][2]))


a = int(input())
for i in range(a):
	(x, y, z) = map(int, input().split())
	if z % 2 == 0:
		if x == y:
			print(0)
		else:
			tot = x * (z // 2) - y * (z // 2)
			print(tot)
	elif x == y:
		print(x)
	else:
		tot = x * (z - z // 2) - y * (z // 2)
		print(tot)


t = int(input())
for i in range(t):
	(a, b, k) = map(int, input().split())
	print(a * (k // 2 + k % 2) - b * (k // 2))


n = int(input())
c = 0
d = []
for i in range(n):
	a = [int(i) for i in input().split()]
	b = a[-1] // 2
	if a[-1] % 2 == 0:
		a1 = a[0] * b - a[1] * b
	else:
		a1 = a[0] * (b + 1) - a[1] * b
	d += [a1]
for i in d:
	print(i)


import sys
num_queries = int(input())
while num_queries > 0:
	(a, b, k) = map(int, input().split(' '))
	right = k // 2
	if k % 2 == 1:
		right += 1
	left = k // 2
	print(a * right - b * left)
	num_queries -= 1


t = int(input())
z = []

def chk(a, b, k):
	if a == b:
		if k % 2 == 0:
			return 0
		else:
			return a
	if k % 2 == 0:
		return k // 2 * (a - b)
	else:
		return (k - 1) // 2 * (a - b) + a
for i in range(t):
	(a, b, k) = map(int, input().split()[:3])
	z.append(chk(a, b, k))
for i in z:
	print(i)


I = lambda : list(map(int, input().split()))
for _ in range(int(input())):
	(a, b, k) = I()
	if k % 2 == 0:
		print(k // 2 * (a - b))
	else:
		print(k // 2 * (a - b) + a)


for i in range(int(input())):
	l = [int(a) for a in input().split()]
	if l[2] % 2 == 0:
		print((l[0] - l[1]) * (l[2] // 2))
	else:
		print((l[0] - l[1]) * (l[2] // 2) + l[0])


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

def read_int():
	return int(stdin.readline())

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
nb_test = read_int()
for _ in range(nb_test):
	(a, b, k) = read_ints()
	if k % 2 == 0:
		print((a - b) * (k // 2))
	else:
		print((a - b) * (k // 2) + a)


t = int(input())
q = []
for i in range(t):
	query = list(map(int, input().split()))
	q.append(query)

def solve(query):
	(a, b, k) = (query[0], query[1], query[2])
	if k % 2 == 0:
		return str(k // 2 * (a - b))
	else:
		return str(k // 2 * (a - b) + a)
res = list(map(solve, q))
print('\n'.join(res))


from math import *
t = int(input(''))
for i in range(t):
	(a, b, k) = map(int, input().split())
	print(k // 2 * (a - b) + (a if k % 2 == 1 else 0))


t = int(input())
Q = [list(map(int, input().split())) for i in range(t)]
for (a, b, k) in Q:
	if k % 2 == 0:
		print((a - b) * k // 2)
	else:
		print((a - b) * (k // 2) + a)


def answer():
	t = int(input())
	while t:
		a = [int(x) for x in input().split()]
		k = a[2]
		p = a[0]
		n = a[1]
		ans = p * (int(k / 2) + k % 2) - n * int(k / 2)
		print(ans)
		t -= 1
answer()


t = int(input())
for cas in range(t):
	(a, b, k) = map(int, input().split())
	ans = (a - b) * (k // 2)
	if k % 2 == 1:
		ans += a
	print(ans)


for _ in range(int(input())):
	(a, b, k) = map(int, input().split())
	if k % 2 == 0:
		print(a * (k // 2) - b * (k // 2))
	else:
		print(a * ((k + 1) // 2) - b * (k - (k + 1) // 2))


t = int(input())
while t:
	(a, b, k) = map(int, input().split())
	ans = (a - b) * (k // 2)
	if k % 2:
		ans += a
	print(ans)
	t -= 1


t = int(input())
while t:
	li = [int(i) for i in input().split()]
	a = li[0]
	b = li[1]
	k = li[2]
	if k % 2 == 0:
		print((a - b) * (k // 2))
	else:
		print((a - b) * (k // 2) + a)
	t -= 1


num = int(input())
arr = [[i for i in input().split()][:3] for y in range(num)]
for i in range(num):
	sum = 0
	if int(arr[i][2]) % 2 == 0:
		sum = int(int(arr[i][2]) / 2) * int(arr[i][0]) - int(int(arr[i][2]) / 2) * int(arr[i][1])
	else:
		sum = int(int(arr[i][2]) / 2 + 1) * int(arr[i][0]) - int(int(arr[i][2]) / 2) * int(arr[i][1])
	print(sum)


for i in range(int(input())):
	(a, b, k) = map(int, input().split())
	ans = 0
	s = k // 2
	if k % 2 == 0:
		ans += (a - b) * s
		print(ans)
	else:
		ans += (a - b) * s
		print(ans + a)


import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *

class Scanner:

	@staticmethod
	def int():
		return int(sys.stdin.readline().rstrip())

	@staticmethod
	def string():
		return sys.stdin.readline().rstrip()

	@staticmethod
	def map_int():
		return [int(x) for x in Scanner.string().split()]

	@staticmethod
	def string_list(n):
		return [input() for i in range(n)]

	@staticmethod
	def int_list_list(n):
		return [Scanner.map_int() for i in range(n)]

	@staticmethod
	def int_cols_list(n):
		return [int(input()) for i in range(n)]

class Math:

	@staticmethod
	def gcd(a, b):
		if b == 0:
			return a
		return Math.gcd(b, a % b)

	@staticmethod
	def lcm(a, b):
		return a * b // Math.gcd(a, b)

	@staticmethod
	def divisor(n):
		res = []
		i = 1
		for i in range(1, int(n ** 0.5) + 1):
			if n % i == 0:
				res.append(i)
				if i != n // i:
					res.append(n // i)
		return res

	@staticmethod
	def round_up(a, b):
		return -(-a // b)

	@staticmethod
	def is_prime(n):
		if n < 2:
			return False
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		d = int(n ** 0.5) + 1
		for i in range(3, d + 1, 2):
			if n % i == 0:
				return False
		return True

class PriorityQueue:

	def __init__(self, l=[]):
		self.q = l
		heapq.heapify(self.q)
		return

	def push(self, n):
		heapq.heappush(self.q, n)
		return

	def pop(self):
		return heapq.heappop(self.q)

def pop_count(x):
	x = x - (x >> 1 & 6148914691236517205)
	x = (x & 3689348814741910323) + (x >> 2 & 3689348814741910323)
	x = x + (x >> 4) & 1085102592571150095
	x = x + (x >> 8)
	x = x + (x >> 16)
	x = x + (x >> 32)
	return x & 127
MOD = int(1000000000.0) + 7
INF = int(1000000000000000.0)

def main():
	T = Scanner.int()
	for _ in range(T):
		(a, b, k) = Scanner.map_int()
		print(a * Math.round_up(k, 2) - b * (k // 2))
main()


q = int(input())
l = []
for x in range(0, q):
	(a, b, k) = map(int, input().split())
	l1 = []
	l1.append(a)
	l1.append(b)
	l1.append(k)
	l.append(l1)
ans_l = []
for i in l:
	if i[2] % 2 == 0:
		ans = int(i[0] * int(i[2] / 2) - i[1] * int(i[2] / 2))
	elif i[2] % 2 != 0:
		ans = int(i[0] * (i[2] - int((i[2] - 1) / 2)) - i[1] * int((i[2] - 1) / 2))
	ans_l.append(ans)
for answ in ans_l:
	print(answ)


num_queries = int(input())
for query in range(num_queries):
	query_params = [int(n) for n in input().split()]
	(a, b, t) = query_params
	if t % 2 == 0:
		result = t // 2 * (a - b)
	else:
		result = (t + 1) // 2 * a - t // 2 * b
	print(result)


test = int(input())
while test > 0:
	test -= 1
	(a, b, k) = map(int, input().split())
	rs = (k + 1) // 2 * a - k // 2 * b
	print(rs)


import math
for _ in range(int(input())):
	(a, b, n) = map(int, input().split())
	ans = 0
	ans = a * math.ceil(n / 2) - b * (n - math.ceil(n / 2))
	print(ans)


t = int(input())
for i in range(t):
	s = 0
	A = input().split()
	a = int(A[0])
	b = int(A[1])
	k = int(A[2])
	if k % 2 == 0:
		k = k // 2
		s = k * a - k * b
	else:
		k = k // 2
		s = (k + 1) * a - k * b
	print(s)


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for i in range(t):
		(a, b, k) = list(map(int, input().split()))
		if k % 2 == 0:
			answer = a * (k // 2) - b * (k // 2)
		else:
			answer = a * (k // 2 + 1) - b * (k // 2)
		print(answer)
	return

def __starting_point():
	main()
__starting_point()


n = int(input())
for _ in range(n):
	(right, left, k) = [int(x) for x in input().split()]
	print(right * (k - k // 2) - left * (k // 2))


queries = int(input())
for x in range(queries):
	(right, left, times) = input().split()
	right = int(right)
	left = int(left)
	times = int(times)
	total = 0
	if right == left and times % 2 == 0:
		total = 0
	elif right == left and times % 2 != 0:
		total = right
	elif times % 2 == 0:
		total = times // 2 * (right - left)
	else:
		total = times // 2 * (right - left) + right
	print(total)


from typing import Iterator

def get_num_input() -> Iterator[int]:
	return map(int, input().split())

def main() -> None:
	right: int
	left: int
	times: int
	(right, left, times) = get_num_input()
	print((right - left) * (times // 2) + right * (times % 2))
ONLY_ONCE: bool = False
for _ in range(1 if ONLY_ONCE else int(input())):
	main()


n = int(input())
for x in range(n):
	(a, b, k) = map(int, input().split())
	if k % 2 == 0:
		c = k // 2
		print(a * c - b * c)
	else:
		c = int(k / 2)
		print(a * (c + 1) - b * c)


def jump(a, b, k):
	if k % 2 == 0:
		return (a - b) * (k // 2)
	else:
		return (a - b) * (k // 2) + a
t = int(input())
for i in range(t):
	(a, b, k) = map(int, input().split())
	result = jump(a, b, k)
	print(result)


t = int(input())
for i in range(t):
	a = [int(i) for i in input().split()]
	print((a[0] - a[1]) * (a[2] // 2) + a[0] * (a[2] % 2))


n = int(input())
for i in range(n):
	(a, b, c) = list(map(int, input().split()))
	x = c // 2 * (a - b)
	if c % 2 == 1:
		x += a
	print(x)


t = int(input())
answer = []
for i in range(t):
	(a, b, k) = map(int, input().split())
	if k % 2 == 1:
		answer.append(k // 2 * (a - b) + a)
	else:
		answer.append(k // 2 * (a - b))
for i in range(t):
	print(answer[i])


import math
t = int(input())
lst = []
for i in range(0, t):
	(a, b, k) = input().split()
	a = int(a)
	b = int(b)
	k = int(k)
	if k % 2 == 0:
		lst.append(k // 2 * a - k // 2 * b)
	else:
		r = math.ceil(k / 2)
		l = k // 2
		lst.append(r * a - l * b)
for a in lst:
	print(a)


t = int(input())

def solve(a, b, k):
	x1 = (a - b) * ((k - k % 2) // 2)
	x2 = 0 if k % 2 == 0 else a
	return x1 + x2
for _ in range(t):
	(a, b, k) = list(map(int, input().split()))
	print(solve(a, b, k))


t = int(input())
for i in range(t):
	(a, b, k) = list(map(int, input().split()))
	ak = (k + 1) // 2
	bk = k - ak
	print(ak * a - bk * b)


x = int(input())
for n in range(x):
	s = [int(n) for n in input().split()]
	a = s[0]
	b = s[1]
	k = s[2]
	m = 0
	p = q = 0
	if k % 2 == 1:
		p = a * (k // 2 + 1)
		q = b * (k // 2)
	else:
		p = a * (k // 2)
		q = b * (k // 2)
	print(p - q)


t = int(input())
while t:
	l = []
	l = [int(x) for x in input().split()]
	a = l[0]
	b = l[1]
	k = l[2]
	p = int(k / 2)
	if k % 2 == 0:
		y = p * a - p * b
	else:
		y = p * a - p * b + a
	print(y)
	t = t - 1


n = int(input())
for _ in range(n):
	arr = [int(num) for num in input().split()]
	a = 0
	if arr[0] != arr[1]:
		if arr[2] % 2 == 0:
			a += arr[2] // 2 * (arr[0] - arr[1])
		else:
			a += (arr[2] // 2 + 1) * arr[0]
			a -= arr[2] // 2 * arr[1]
		print(a)
	elif arr[2] % 2 == 0:
		print(0)
	else:
		print(arr[0])


t = int(input())
res = []
for i in range(t):
	x = 0
	a = list(map(int, input().split()))
	if a[2] % 2 == 0:
		x = x + a[0] * (a[2] // 2) - a[1] * (a[2] // 2)
	else:
		x = x + a[0] * (a[2] // 2 + 1) - a[1] * (a[2] // 2)
	res.append(x)
for i in res:
	print(i)


from decimal import Decimal
from math import ceil
from math import floor
querys = int(input())
count = querys
rightj = []
leftj = []
jumps = []
totaljumps = []
while count > 0:
	(right, left, jump) = input().split()
	right = Decimal(right)
	left = Decimal(left)
	jump = Decimal(jump)
	rightj.append(right)
	leftj.append(left)
	jumps.append(jump)
	totaljump = 0
	if jump % 2 == 0:
		totaljump -= left * jump / 2
		totaljump += right * jump / 2
	else:
		totaljump -= left * floor(jump / 2)
		totaljump += right * ceil(jump / 2)
	count -= 1
	totaljumps.append(totaljump)
while count < querys:
	print(totaljumps[count])
	count += 1


rd = lambda : list(map(int, input().split()))

def main():
	n = int(input())
	for i in range(n):
		(a, b, k) = rd()
		t = a - b
		if k % 2 == 0:
			l = t * int(k / 2)
			print(l)
		else:
			l = t * int((k - 1) / 2)
			l += a
			print(l)
main()


t = int(input())
for i in range(t):
	T = input().split(' ')
	(a, b, k) = (int(T[0]), int(T[1]), int(T[2]))
	s = (k // 2 + k % 2) * a - k // 2 * b
	print(s)


t = int(input())
for j in range(t):
	(a, b, k) = map(int, input().split())
	if k % 2 != 0:
		print((k // 2 + 1) * a - b * (k - k // 2 - 1))
	else:
		print(k // 2 * a - b * (k - k // 2))


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	if c % 2:
		d = c // 2
		e = a * (d + 1) - b * d
		print(e)
	else:
		d = c // 2
		e = a * d - b * d
		print(e)


n = int(input())
j = 0
for i in range(n):
	(a, b, k) = map(int, input().split())
	m = k % 2
	if m == 0:
		m = k // 2
		j = m
	else:
		j = k // 2 + 1
		m = k // 2
	l = int(a * j) + int(b * -m)
	print(l)


n = int(input())
for _ in range(n):
	x = [int(i) for i in input().split()]
	(a, b, k) = (x[0], x[1], x[2])
	print((a - b) * (k // 2) + a * (k % 2))


T = int(input())
for t in range(T):
	(a, b, c) = list(map(int, input().split()))
	ans = a * ((c + 1) // 2) - b * (c // 2)
	print(ans)


x = int(input())
y = 0
for i in range(x):
	(r, l, n) = map(int, input().split())
	if n % 2 == 0:
		y = n // 2 * r - n // 2 * l
	else:
		y = n // 2 * r - n // 2 * l + r
	print(y)


for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	print(int(c / 2) * (a - b) + a * (c % 2))


t = int(input())
res = list()
for i in range(t):
	(a, b, k) = list(map(int, input().strip().split()))
	pos = None
	if a == 0:
		pos = k * b
	elif b == 0:
		pos = k * a
	else:
		pos = a * k - k // 2 * (a + b)
	res.append(int(pos))
for i in res:
	print(i)


for i in range(int(input())):
	(a, b, k) = map(int, input().split())
	ans = (a - b) * (k // 2) + a * (k & 1)
	print(ans)


import math
for _ in range(int(input())):
	(a, b, k) = map(int, input().split(' '))
	p = int(math.ceil(k / 2))
	print(a * p - b * (k - p))


def solve(a, b, k):
	v = (a - b) * (k // 2) + a * (k % 2)
	return v
n = int(input())
for i in range(n):
	print(solve(*map(int, input().split())))


t = int(input())
import math
for _ in range(t):
	(a, b, k) = map(int, input().split())
	temp = math.ceil(k / 2)
	temp1 = k - temp
	print(a * temp - b * temp1)


t = int(input())
for i in range(t):
	(a, b, k) = list(map(int, input().split()))
	ans = (a - b) * (k // 2)
	if k % 2 == 1:
		ans += a
	print(ans)


n = int(input())
for i in range(n):
	pos = 0
	(a, b, k) = map(int, input().split())
	if k % 2 == 0:
		pos = k // 2 * (a - b)
	else:
		k = k - 1
		pos = k // 2 * (a - b)
		pos += a
	print(pos)


n = int(input())
while n > 0:
	(a, b, k) = map(int, input().split())
	if k % 2 == 1:
		print((k - k // 2) * a - k // 2 * b)
	else:
		print(k // 2 * a - k // 2 * b)
	n = n - 1


def main():
	t = int(input())
	for i in range(t):
		(a, b, k) = map(int, input().split())
		pos = (a - b) * (k // 2)
		pos += a * (k % 2)
		print(pos)
main()


n = int(input())
Q = []
for _ in range(n):
	Q.append(list(map(int, input().split())))
for (a, b, k) in Q:
	y = int(k / 2)
	x = k - y
	print(a * x - b * y)


q = int(input())
for i in range(q):
	a = list(map(int, input().split()))
	k = a[2]
	if k % 2 == 0:
		print((a[0] - a[1]) * (k // 2))
	else:
		print(a[0] * (k // 2 + 1) - a[1] * (k // 2))


import math
t = int(input())
for i in range(t):
	(a, b, k) = map(int, input().split())
	if a == b:
		if k % 2 == 0:
			print(0)
		else:
			print(a)
	else:
		x = 0
		v = int(math.ceil(k / 2))
		if k % 2 == 0:
			x += v * a
			x -= v * b
			print(x)
		else:
			x += v * a
			x -= (v - 1) * b
			print(x)


c = int(input())
i = 0
while i < c:
	ab = input().split()
	a = int(ab[0])
	b = int(ab[1])
	k = int(ab[2])
	if k % 2 != 0:
		print(a * (int(k / 2) + 1) - b * int(k / 2))
	else:
		print(a * int(k / 2) - b * int(k / 2))
	i = i + 1


t = int(input())
for x in range(t):
	(a, b, k) = [int(x) for x in input().split()]
	pos = (a - b) * (k // 2)
	if k % 2 != 0:
		pos += a
	print(pos)


import math
n = int(input())
M = [input().split() for i in range(n)]
J = []

def jump(a, b, k):
	if k % 2 == 0:
		x = k // 2 * a - k // 2 * b
	else:
		x = math.floor(k / 2) * a - math.floor(k / 2) * b + a
	J.append(x)
for i in range(n):
	for j in range(3):
		M[i][j] = int(M[i][j])
for i in M:
	x = i[0]
	y = i[1]
	z = i[2]
	jump(x, y, z)
for i in J:
	print(int(i))


x = int(input())
for _ in range(x):
	(a, b, c) = map(int, input().split())
	if c % 2 == 0:
		print((a - b) * (c // 2))
	else:
		print((a - b) * (c // 2) + a)


for _ in range(int(input())):
	(a, b, k) = map(int, input().split())
	if k % 2 == 0:
		print(int(a - b) * int(k / 2))
	elif k % 2 != 0:
		print(int(a - b) * int(k / 2) + a)


t = int(input())
for i in range(t):
	(a, b, k) = map(int, input().strip().split())
	diff = a - b
	if k % 2 == 0:
		print(diff * k // 2)
	else:
		print(diff * (k - 1) // 2 + a)


tests = int(input())
end = []
for i in range(tests):
	(a, b, t) = list(map(lambda x: int(x), input().split(' ')))
	if t % 2 == 0:
		ans = (a - b) * (t // 2)
	else:
		ans = (a - b) * (t // 2) + a
	end.append(str(ans))
print('\n'.join(end))


n = int(input())
for i in range(n):
	res = 0
	text = input().split()
	nj = int(text[2])
	rj = int(text[0])
	lj = int(text[1])
	if rj == lj and nj % 2 == 0:
		print(0)
	elif rj == lj and nj % 2 != 0:
		print(rj)
	else:
		if nj % 2 == 0:
			res = int(nj / 2) * rj - int(nj / 2) * lj
		else:
			res = (int(nj / 2) + 1) * rj - int(nj / 2) * lj
		print(int(res))


for i in range(int(input())):
	(a, b, k) = map(int, input().split())
	x = k // 2
	y = k - x
	ans = y * a - x * b
	print(ans)


n = int(input())
for i in range(n):
	l = list(map(int, input().split()))
	a = l[2] - l[2] // 2
	b = l[2] // 2
	print(a * l[0] - b * l[1])


t = int(input())
for _ in range(t):
	(a, b, k) = map(int, input().split())
	r = a * ((k + 1) // 2)
	l = b * (k // 2)
	print(r - l)


t = int(input())
for it in range(t):
	(a, b, k) = map(int, input().split())
	if k % 2 == 0:
		print((a - b) * (k // 2))
	else:
		print((a - b) * (k // 2) + a)


hm = int(input())
for _ in range(hm):
	(a, b, k) = map(int, input().split())
	print((a - b) * (k // 2) + a * (k % 2 == 1))


t = int(input())
for i in range(t):
	list1 = input().split()
	a = int(list1[0])
	b = int(list1[1])
	k = int(list1[2])
	x = 0
	if k % 2 == 0:
		print(a * (k // 2) - b * (k // 2))
	else:
		x += a
		k -= 1
		print(x + a * (k // 2) - b * (k // 2))


gcd = lambda a, b: gcd(b, a % b) if b else a

def main():
	t = int(input())
	for _ in range(t):
		(a, b, c) = map(int, input().split())
		total = 0
		total -= b * (c // 2)
		total += a * (c // 2)
		if c % 2:
			total += a
		print(total)
main()


t = int(input())
for inh in range(0, t):
	(a, b, k) = map(int, input().split())
	one = a - b
	n = k // 2
	pre = one * n
	if k % 2 == 1:
		pre += a
	print(pre)


from sys import stdin, stdout
import cProfile, math
from collections import Counter
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10000000)

class Operation:

	def __init__(self, name, function, function_on_equal, neutral_value=0):
		self.name = name
		self.f = function
		self.f_on_equal = function_on_equal

def add_multiple(x, count):
	return x * count

def min_multiple(x, count):
	return x

def max_multiple(x, count):
	return x
sum_operation = Operation('sum', sum, add_multiple, 0)
min_operation = Operation('min', min, min_multiple, 1000000000.0)
max_operation = Operation('max', max, max_multiple, -1000000000.0)

class SegmentTree:

	def __init__(self, array, operations=[sum_operation, min_operation, max_operation]):
		self.array = array
		if type(operations) != list:
			raise TypeError('operations must be a list')
		self.operations = {}
		for op in operations:
			self.operations[op.name] = op
		self.root = SegmentTreeNode(0, len(array) - 1, self)

	def query(self, start, end, operation_name):
		if self.operations.get(operation_name) == None:
			raise Exception('This operation is not available')
		return self.root._query(start, end, self.operations[operation_name])

	def summary(self):
		return self.root.values

	def update(self, position, value):
		self.root._update(position, value)

	def update_range(self, start, end, value):
		self.root._update_range(start, end, value)

	def __repr__(self):
		return self.root.__repr__()

class SegmentTreeNode:

	def __init__(self, start, end, segment_tree):
		self.range = (start, end)
		self.parent_tree = segment_tree
		self.range_value = None
		self.values = {}
		self.left = None
		self.right = None
		if start == end:
			self._sync()
			return
		self.left = SegmentTreeNode(start, start + (end - start) // 2, segment_tree)
		self.right = SegmentTreeNode(start + (end - start) // 2 + 1, end, segment_tree)
		self._sync()

	def _query(self, start, end, operation):
		if end < self.range[0] or start > self.range[1]:
			return None
		if start <= self.range[0] and self.range[1] <= end:
			return self.values[operation.name]
		self._push()
		left_res = self.left._query(start, end, operation) if self.left else None
		right_res = self.right._query(start, end, operation) if self.right else None
		if left_res is None:
			return right_res
		if right_res is None:
			return left_res
		return operation.f([left_res, right_res])

	def _update(self, position, value):
		if position < self.range[0] or position > self.range[1]:
			return
		if position == self.range[0] and self.range[1] == position:
			self.parent_tree.array[position] = value
			self._sync()
			return
		self._push()
		self.left._update(position, value)
		self.right._update(position, value)
		self._sync()

	def _update_range(self, start, end, value):
		if end < self.range[0] or start > self.range[1]:
			return
		if start <= self.range[0] and self.range[1] <= end:
			self.range_value = value
			self._sync()
			return
		self._push()
		self.left._update_range(start, end, value)
		self.right._update_range(start, end, value)
		self._sync()

	def _sync(self):
		if self.range[0] == self.range[1]:
			for op in self.parent_tree.operations.values():
				current_value = self.parent_tree.array[self.range[0]]
				if self.range_value is not None:
					current_value = self.range_value
				self.values[op.name] = op.f([current_value])
		else:
			for op in self.parent_tree.operations.values():
				result = op.f([self.left.values[op.name], self.right.values[op.name]])
				if self.range_value is not None:
					bound_length = self.range[1] - self.range[0] + 1
					result = op.f_on_equal(self.range_value, bound_length)
				self.values[op.name] = result

	def _push(self):
		if self.range_value is None:
			return
		if self.left:
			self.left.range_value = self.range_value
			self.right.range_value = self.range_value
			self.left._sync()
			self.right._sync()
			self.range_value = None

	def __repr__(self):
		ans = '({}, {}): {}\n'.format(self.range[0], self.range[1], self.values)
		if self.left:
			ans += self.left.__repr__()
		if self.right:
			ans += self.right.__repr__()
		return ans

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def primeFactors(n):
	factors = dict()
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		while n % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			n = n // i
	if n > 2:
		factors[n] = 1
	return factors

def isprime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True

def test_print(*args):
	if testingMode:
		print(args)

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))
memory = dict()

def clear_cache():
	global memory
	memory = dict()

def cached_fn(fn, *args):
	global memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result
TestCases = True
testingMode = False
optimiseForReccursion = False

def main():
	(a, b, k) = get_tuple()
	if k % 2 == 0:
		print((a - b) * (k // 2))
	else:
		print((a - b) * (k // 2) + a)
if TestCases:
	for _ in range(get_int()):
		cProfile.run('main()') if testingMode else main()
else:
	(cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()


n = int(input())
for i in range(n):
	value = 0
	(a, b, k) = map(int, input().split())
	if k % 2 == 0:
		t = k // 2
		value = t * (a - b)
	else:
		t = k // 2
		value = (k - t) * a - t * b
	print(value)


for i in range(int(input())):
	(a, b, n) = map(int, input().split())
	if n % 2:
		print((a - b) * (n // 2) + a)
	else:
		print((a - b) * (n // 2))


def main():
	n = int(input())
	for i in range(n):
		(a, b, k) = [int(v) for v in input().split()]
		d = k // 2
		s = a * d + -1 * b * d
		if k % 2 != 0:
			s += a
		print(s)
main()


n = int(input())
hasil = 0
for i in range(n):
	angka = input().split()
	if int(angka[2]) % 2 == 0:
		hasil += (int(angka[0]) - int(angka[1])) * (int(angka[2]) // 2)
	else:
		hasil += (int(angka[0]) - int(angka[1])) * (int(angka[2]) // 2) + int(angka[0])
	print(hasil)
	hasil = 0


t = int(input())
for i in range(t):
	listnum = [int(f) for f in input().split()]
	a = listnum[0]
	b = listnum[1]
	k = listnum[2]
	x = 0
	if k % 2 == 0:
		ao = k // 2
		ai = k // 2
	elif k % 2 == 1:
		ao = k // 2 + 1
		ai = k // 2
	x = ao * a + ai * -b
	print(x)


t = int(input())
ans = []
for i in range(t):
	x = 0
	odd = False
	(a, b, k) = map(int, input().split(' '))
	if k % 2 != 0:
		k += 1
		odd = True
	x += a * (k // 2)
	x -= b * (k // 2)
	if odd == True:
		x += b
	ans.append(x)
for i in range(t):
	print(ans[i])


x = int(input())
y = []
for i in range(x):
	y.append(list(map(int, input().split(' '))))
for i in range(x):
	if y[i][2] % 2 == 0:
		a = y[i][2] // 2 * (y[i][0] - y[i][1])
		print(a)
	else:
		b = y[i][2] // 2 * y[i][0] - y[i][2] // 2 * y[i][1] + y[i][0]
		print(b)


n = int(input())
for i in range(n):
	k = list(map(int, input().split()))
	if k[2] % 2 == 0:
		t = k[2] // 2
		print(k[0] * t - k[1] * t)
	else:
		t = k[2] // 2
		s = t + 1
		print(k[0] * s - k[1] * t)


t = int(input())
result = str()
for i in range(t):
	(a, b, k) = list(map(int, input().split()))
	if k % 2:
		result = f'{result}\n{a * (k // 2 + 1) - b * (k // 2)}'.strip()
	else:
		result = f'{result}\n{(a - b) * k // 2}'.strip()
print(result)


t = int(input())
all_data = []
for i in range(t):
	data = [int(i) for i in input().split(' ')]
	all_data.append(data)
for i in all_data:
	right = i[0]
	left = i[1]
	k = i[2]
	jump = right - left
	if k % 2 == 0:
		print(jump * (k // 2))
	else:
		print(jump * (k // 2) + right)


for _ in range(int(input())):
	(r, l, n) = map(int, input().split())
	cnt = 0
	temp = r - l
	if not n & 1:
		print(n // 2 * temp)
	else:
		ans = n // 2 * temp + r
		print(ans)


import math
for _ in range(int(input())):
	b = list(map(int, input().split()))
	print(b[0] * math.ceil(b[2] / 2) - b[1] * int(b[2] / 2))


import math
for _ in range(int(input())):
	(a, b, k) = list(map(int, input().split()))
	ans = a * math.ceil(k / 2) - b * (k // 2)
	print(ans)


t = int(input())
l = []
ans = []
for i in range(t):
	a = []
	st = input()
	a = st.split(' ')
	l.append(a)
for i in range(t):
	a = int(l[i][0])
	b = int(l[i][1])
	k = int(l[i][2])
	sum = 0
	if k % 2 != 0:
		k1 = int(k / 2) + 1
		sum = a * k1 - b * (k - k1)
	else:
		k1 = int(k / 2)
		sum = a * k1 - b * k1
	ans.append(sum)
for i in range(len(ans)):
	print(ans[i])


t = int(input())
if 1 <= t <= 1000:
	for i in range(t):
		(a, b, k) = input().split()
		a = int(a)
		b = int(b)
		k = int(k)
		if k % 2 == 0:
			l = k // 2
			m = a - b
			n = m * l
			n = int(n)
			print(n)
		elif k % 2 != 0:
			l = k // 2
			m = a * (l + 1) - b * l
			m = int(m)
			print(m)


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())
for i in range(int(input())):
	(a, b, k) = get_ints()
	diff = a - b
	if k % 2 == 0:
		print(diff * (k // 2))
	else:
		print(diff * (k // 2) + a)


t = int(input())
for i in range(t):
	(a, b, k) = map(int, input().split())
	if k % 2 != 0:
		f = (k // 2 + 1) * a - k // 2 * b
		print(f)
	elif k % 2 == 0:
		f = k // 2 * a - k // 2 * b
		print(f)


import math
for _ in range(int(input())):
	(a, b, k) = [int(i) for i in input().strip().split(' ')]
	print(math.ceil(k / 2) * a - int(k / 2) * b)


list1 = []
for i in range(int(input())):
	list2 = list(map(int, input().split()))
	list1.append(list2[0] * (list2[2] // 2 + list2[2] % 2) - list2[1] * (list2[2] // 2))
for i in list1:
	print(i)


t = int(input())
for i in range(t):
	(a, b, k) = map(int, input().split())
	if k & 1:
		print((k + 1 >> 1) * a - (k - 1 >> 1) * b)
	else:
		print((k >> 1) * a - (k >> 1) * b)


def ans(arr):
	(a, b, k) = (arr[0], arr[1], arr[2])
	net = a - b
	jump = k // 2
	if k % 2 == 0:
		return net * jump
	else:
		return net * jump + a
t = int(input())
for _ in range(t):
	n = list(map(int, input().strip().split()))
	print(ans(n))


from sys import stdin, stdout
from math import ceil, floor
for _ in range(0, int(stdin.readline())):
	(a, b, k) = map(int, stdin.readline().split())
	res = a * ceil(k / 2) - b * floor(k / 2)
	stdout.write(f'{res}\n')


t = int(input())
i = int(1)
while i <= t:
	(a, b, k) = input().split(' ')
	a = int(a)
	b = int(b)
	k = int(k)
	if k % 2 == 0:
		sum1 = int(a * (k // 2))
		sum2 = int(b * (k // 2))
		print(sum1 - sum2)
	else:
		sum1 = int(a * (k // 2) + a)
		sum2 = int(b * (k // 2))
		print(sum1 - sum2)
	i = i + 1


test_cases = int(input())
for i in range(test_cases):
	(r, l, steps) = map(int, input().split(' '))
	halfSteps = steps // 2
	moves = halfSteps * r - halfSteps * l
	if steps % 2 == 0:
		print(moves)
	else:
		print(moves + r)


t = int(input())
while t != 0:
	(a, b, k) = map(int, input().split(' '))
	if k % 2 == 0:
		a = a - b
		k = int(k / 2)
		print(a * k)
	else:
		lol = a
		a = a - b
		k = int((k - 1) / 2)
		print(a * k + lol)
	t = t - 1


t = int(input())
for i in range(t):
	(a, b, k) = list(map(int, input().split()))
	num0 = k // 2
	num1 = k - num0
	print(num1 * a - num0 * b)


n = int(input())
res = []
for i in range(n):
	(a, b, c) = map(int, input().split())
	if c % 2 == 0:
		res.append((a - b) * (c // 2))
	else:
		res.append(a * (c // 2 + 1) - b * (c // 2))
for i in res:
	print(i)


import math
f = 0
arr = []
t = int(input())
for i in range(0, t):
	(a, b, k) = input().split()
	a = int(a)
	b = int(b)
	k = int(k)
	f = a * math.ceil(k / 2)
	f -= b * (k // 2)
	arr.append(f)
	f = 0
for ar in arr:
	print(ar)


n = int(input())
array = []
for i in range(n):
	(a, b, k) = input().split()
	a = int(a)
	b = int(b)
	k = int(k)
	f = k // 2
	s = k - f
	array.append(a * s - b * f)
for n in array:
	print(n)


import math
t = int(input())
for i in range(t):
	(a, b, k) = map(int, input().split())
	r = math.ceil(k / 2)
	print(r * a + (r - k) * b)


for _ in [0] * int(input()):
	(a, b, k) = map(int, input().split())
	print(k // 2 * (a - b) + k % 2 * a)


n = int(input())
requests = []
for _ in range(n):
	query = list(map(int, input().split(' ')))
	requests.append(query)
res = []
for request in requests:
	a = request[0]
	b = request[1]
	k = request[2]
	if k % 2 != 0:
		res.append((a - b) * (k - 1) // 2 + a)
	else:
		res.append((a - b) * k // 2)
for re in res:
	print(re)


import sys
from math import floor, ceil
input = sys.stdin.readline
t = int(input())
for zzz in range(t):
	(r, l, k) = list(map(int, input().split()))
	print(ceil(k / 2) * r - floor(k / 2) * l)


t = int(input())
for i in range(t):
	(a, b, c) = list(map(int, input().split()))
	(x, y, z) = (0, 0, 0)
	if c % 2 == 0:
		steps = int(c / 2)
		tot = a * steps - b * steps
	elif c % 2 == 1:
		steps = int(c / 2)
		tot = a * (steps + 1) - b * steps
	print(tot)


t = int(input())
for _ in range(t):
	(a, b, k) = map(int, input().split())
	s = (a - b) * (k // 2) + a * (k % 2)
	print(s)


t = int(input())
for i in range(t):
	(x, y, z) = list(map(int, input().split()))
	if z % 2 == 0:
		print(int(z / 2) * x - int(z / 2) * y)
	else:
		print(int((z + 1) / 2) * x - int(z / 2) * y)


n = int(input())
for i in range(n):
	(a, b, k) = [int(i) for i in input().split()]
	print(k // 2 * (a - b) + k % 2 * a, end=' ')


a = int(input())
b = [list(map(int, input().split())) for i in range(a)]
for i in b:
	c = 0
	if i[2] % 2 == 0:
		c = i[0] * (i[2] // 2) - i[1] * (i[2] // 2)
	else:
		c = i[0] * (i[2] // 2 + 1) - i[1] * (i[2] // 2)
	print(int(c))


n = int(input())
for i in range(n):
	(a, b, k) = map(int, input().split())
	print((a - b) * (k // 2) + a * abs(k % 2))


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	if c % 2 == 0:
		print((a - b) * (c // 2))
	else:
		print((a - b) * (c // 2) + a)


s = input()
while True:
	try:
		(a, b, c) = map(int, input().split(' '))
		res = 0
		if c % 2 == 0:
			res = (a - b) * (c // 2)
		else:
			res = (a - b) * (c - 1) // 2 + a
		print(res)
	except:
		break


t = int(input())
for i in range(t):
	(a, b, k) = (int(s) for s in input().split())
	x = (a - b) * (k // 2)
	if k % 2 != 0:
		x += a
	print(x)


for i in range(int(input())):
	(a, b, k) = [int(w) for w in input().split()]
	print(a * int(k / 2) - b * int(k / 2) if k % 2 == 0 else a * (int(k / 2) + 1) - b * int(k / 2))


n = int(input())
l = []
for i in range(0, n, 1):
	l.append(list(map(int, input().split())))
for i in range(0, n, 1):
	dist = 0
	if l[i][2] % 2 == 0:
		dist = (l[i][0] - l[i][1]) * (l[i][2] // 2)
	else:
		dist = l[i][0]
		l[i][2] = l[i][2] - 1
		dist = dist + (l[i][0] - l[i][1]) * (l[i][2] // 2)
	print(int(dist))


for _ in range(int(input())):
	(a, b, k) = map(int, input().split())
	x = k >> 1
	k -= x
	print(a * k - b * x)