Bob has an account in the Bobby Bank. His current account balance is W rupees. 

Each month, the office in which Bob works deposits a fixed amount of X rupees to his account.  
Y rupees is deducted from Bob's account each month as bank charges. 

Find his final account balance after Z months. Note that the account balance can be negative as well.

------ Input Format ------ 

- The first line will contain T, the number of test cases. Then the test cases follow.
- Each test case consists of a single line of input, containing four integers W,X,Y, and Z — the initial amount, the amount deposited per month, the amount deducted per month, and the number of months.

------ Output Format ------ 

For each test case, output in a single line the final balance in Bob's account after Z months.

------ Constraints ------ 

$1 ≤ T ≤ 1000$ 
$1 ≤ W,X,Y,Z ≤ 10^{4}$

----- Sample Input 1 ------ 
3
100 11 1 10
999 25 36 9
2500 100 125 101

----- Sample Output 1 ------ 
200
900
-25
----- explanation 1 ------ 
Test case $1$: Bob's current account balance is $100$. At the end of each month Bob gets Rs $11$ and pays Rs $1$, thus gaining $10$ per month. Thus, at the end of $10$ months, Bob will have $100 + 10 \times 10 = 200$.

Test case $2$: Bob's current account balance is $999$. At the end of each month Bob gets Rs $25$ and pays Rs $36$, thus losing $11$ per month. Thus, at the end of $9$ months, Bob will have $999 - 11 \times 9 = 900$.

Test case $3$: Bob's current account balance is $2500$. At the end of each month Bob gets Rs $100$ and pays Rs $125$, thus losing $25$ per month. Thus, at the end of $101$ months, Bob will have $2500 - 25 \times 101 = -25$.

Source: codechef | Difficulty: EASY


Solutions:
a = int(input())
for i in range(a):
	(b, c, d, e) = [int(x) for x in input().split()]
	f = c - d
	print(b + f * e)


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


t = int(input())
for i in range(t):
	(w, x, y, z) = map(int, input().split())
	if x > y:
		print(w + (x - y) * z)
	else:
		print(w - (y - x) * z)


t = int(input())
for t in range(t):
	(w, x, y, z) = map(int, input().split())
	print(w + (x - y) * z)


t = int(input())
for i in range(t):
	(w, x, y, z) = map(int, input().split())
	a = x * z
	b = y * z
	print(w + (a - b))


n = int(input())
for i in range(n):
	c = 0
	l = 0
	k = 0
	(w, x, y, z) = map(int, input().split())
	l = x - y
	k = l * z
	print(k + w)


t = int(input())
for i in range(t):
	(w, x, y, z) = map(int, input().split())
	u = x - y
	v = u * z
	print(w + v)


t = int(input())
for i in range(t):
	(W, X, Y, Z) = map(int, input().split())
	total_per_Z_months = (X - Y) * Z
	nett_account = W + total_per_Z_months
	print(nett_account)


T = int(input())
for i in range(T):
	(W, X, Y, Z) = map(int, input().split())
	per_month = X - Y
	end_of_ten = W + per_month * Z
	print(end_of_ten)


a = int(input())
for i in range(a):
	(w, x, y, z) = map(int, input().split())
	p = x - y
	print(w + p * z)


for i in range(int(input())):
	(x, y, z, w) = map(int, input().split())
	k = x + (y - z) * w
	print(k)


for i in range(int(input())):
	(W, X, Y, Z) = map(int, input().split())
	amount = X - Y
	final_amount = Z * amount
	print(final_amount + W)


T = int(input())
for i in range(T):
	(w, x, y, z) = [int(j) for j in input().split()]
	result = w + z * (x - y)
	print(result)


n = int(input())
for i in range(0, n):
	(w, x, y, z) = map(int, input().split(' '))
	print(w + (x - y) * z)


for i in range(int(input())):
	(W, X, Y, Z) = map(int, input().split())
	balance = W + Z * (X - Y)
	print(balance)


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	print(l[0] + (l[1] - l[2]) * l[3])


t = int(input())
for i in range(t):
	(w, x, y, z) = list(map(int, input().split()))
	r = w + (x - y) * z
	print(r)


a = int(input())
for i in range(a):
	(s, d, f, g) = map(int, input().split())
	amt = s + (d - f) * g
	print(amt)


for t in range(int(input())):
	(s, k, d, v) = map(int, input().split())
	l = k - d
	print(s + l * v)


t = int(input())
while t:
	(w, x, y, z) = map(int, input().split())
	print(w + (x - y) * z)
	t -= 1


t = int(input())
for i in range(t):
	(w, x, y, z) = input().split()
	(w, x, y, z) = (int(w), int(x), int(y), int(z))
	accbalance = w + (x - y) * z
	print(accbalance)


def abalance(w, x, y, z):
	r = x - y
	w = w + r * z
	return w
t = int(input())
for i in range(1, t + 1):
	(w, x, y, z) = map(int, input().split())
	res = abalance(w, x, y, z)
	print(res)


t = int(input())
while t:
	(a, b, c, d) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	d = int(d)
	k = b - c
	print(a + k * d)
	t -= 1


for i in range(int(input())):
	(w, x, y, z) = map(int, input().split())
	deduct = x - y
	final_balance = w + deduct * z
	print(final_balance)


n = int(input())
for i in range(n):
	(a, b, c, d) = list(map(int, input().split()))
	e = b - c
	print(a + e * d)


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	k = d * b
	p = c * d
	print(a + (k - p))


n = int(input())
for i in range(n):
	(a, b, c, d) = map(int, input().split())
	f = b - c
	g = f * d
	h = g + a
	print(h)


p = int(input())
for i in range(p):
	(p, q, r, s) = map(int, input().split())
	x = q - r
	f = p + x * s
	print(f)


a = int(input())
for i in range(a):
	(b, c, d, e) = map(int, input().split())
	f = c - d
	g = f * e
	print(b + g)


n = int(input())
for i in range(n):
	lst = list(map(int, input().split()))[:4]
	print(lst[0] + (lst[1] - lst[2]) * lst[3])


t = int(input())
while t != 0:
	(a, b, c, d) = map(int, input().split())
	s = b - c
	print(s * d + a)
	t = t - 1


t = int(input())
for i in range(t):
	(w, x, y, z) = map(int, input().split())
	after = x - y
	total = after * z
	overall = w + total
	print(overall)


for i in range(int(input())):
	(w, x, y, z) = list(map(int, input().split()))
	m = (x - y) * z
	print(m + w)


for i in range(int(input())):
	(w, x, y, z) = map(int, input().split())
	diff = x - y
	mul = diff * z
	print(w + mul)


n = int(input())
for tc in range(n):
	(a, b, c, d) = map(int, input().split())
	e = a + (b - c) * d
	print(e)


t = int(input())
for i in range(t):
	(x, y, z, l) = map(int, input().split())
	if y > z:
		diff1 = y - z
		print(x + diff1 * l)
	else:
		diff2 = z - y
		print(x - diff2 * l)


T = int(input())
for num in range(0, T):
	(W, X, Y, Z) = map(int, input().split())
	a = X - Y
	b = a * Z
	print(W + b)


for _ in range(int(input())):
	(W, X, Y, Z) = map(int, input().split())
	print(W - Z * Y + Z * X)