A fast-food chain menu is selling a burger, a can of soda, and a combo meal containing a burger and a can of soda, at prices known to you. 

They have chosen the selling price for each item by first determining the total cost of making the individual items and then adding a fixed value to it, representing their profit. Assume that the cost of making a regular burger is fixed and the cost of making a regular soda is fixed.

For example, if the cost of making a regular burger is ${206}$, the cost of making a regular soda is $145$ and the fixed profit is $\mbox{69}$, then the fast-food chain will set selling prices as:

Given the price of a burger, a can of soda and a combo meal on the menu, your task is to compute the fixed profit. 

Complete the function named profit which takes in three integers denoting selling price of a burger, a can of soda and a combo meal respectively, and returns an integer denoting the fixed profit. 

Input Format

The first line contains ${t}}$, the number of scenarios. The following lines describe the scenarios.  

Each scenario is described by a single line containing three space-separated integers, ${b}$, ${s}}$ and ${c}$, denoting how much a burger, a can of soda and a combo meal cost respectively.

Constraints

$1\leq t\leq100$  
$3\leq c\leq2000$  
$2\leq b,s<c$  
It is guaranteed that the cost of making each item and the profit are positive.  

Output Format

For each scenario, print a single line containing a single integer denoting the profit that the fast-food chain gets from every purchase. It is guaranteed that the answer is positive.  

Sample Input 0
3
275 214 420
6 9 11
199 199 255

Sample Output 0
69
4
143

Explanation 0

Case 1: Refer to the problem statement for this case.

Case 2: The selling price of a burger is ${6}$, soda is ${9}$, and combo meal is ${11}$. If the cost to make a burger is $2$, the cost to make a can of soda is $5$ and the fixed profit is ${4}$, you can verify the given selling prices as, $b=2+4,s=5+4$ and $c=2+5+4$. Hence, the answer is ${4}$.

Case 3: The selling price of a burger is ${199}$, soda is $f{199}$, and combo meal is $255$. If the cost to make a burger is $56$, the cost to make a can of soda is $56$ and the fixed profit is $143$, you can verify the given selling prices as, $b=56+143,s=56+143$ and $c=56+56+143$. Hence, the answer is $143$.

Source: hackerrank | Difficulty: EASY
Tags: Matrices


Solutions:
import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return -1 * (c - (s + b))
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return abs(c - b - s)
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return abs(c - b - s)
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b - c + s
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	print(abs(c - a - b))


import sys

def profit(b, s, c):
	return -(c - b - s)
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


def game(a, b, c):
	return a + b - c
for _ in range(int(input())):
	(a, b, c) = [int(x) for x in input().split()]
	print(game(a, b, c))


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return abs(c - b - s)
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return -(c - b - s)
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return abs(c - s - b)
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


T = int(input())
for t in range(T):
	v = list((int(x) for x in input().split()))
	print(v[0] + v[1] - v[2])


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return -1 * (c - b - s)
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return -(c - b - s)
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	x = c - s
	t = b - x
	return t
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	for i in range(min(b, s, c)):
		if b - i + s - i == c - i:
			return i
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return abs(c - b - s)
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


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


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


from collections import defaultdict as dd
t = int(input())
while t > 0:
	(b, s, c) = map(int, input().split())
	print(abs(c - b - s))
	t -= 1


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


for i in range(int(input())):
	(n, m, k) = [int(x) for x in input().split()]
	print(n + m - k)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return abs(c - b - s)
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	ans = b + s - c
	return ans
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return abs(c - (b + s))
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return abs(c - s - b)
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return s + b - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	a = b + s
	p = a - c
	return p
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	tmp_combo = b + s
	return tmp_combo - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	i = 0
	while i < c:
		if c - i == b + s - i - i:
			return i
		i += 1
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)


import sys

def profit(b, s, c):
	return b + s - c
t = int(input().strip())
for a0 in range(t):
	(b, s, c) = input().strip().split(' ')
	(b, s, c) = [int(b), int(s), int(c)]
	result = profit(b, s, c)
	print(result)