description: Some number of people (this number is even) have stood in a circle. The people stand in the circle evenly. They are numbered clockwise starting from a person with the number 1. Each person is looking through the circle's center at the opposite person.
  
  <image> A sample of a circle of 6 persons. The orange arrows indicate who is looking at whom.
  
  You don't know the exact number of people standing in the circle (but this number is even, no doubt). It is known that the person with the number a is looking at the person with the number b (and vice versa, of course). What is the number associated with a person being looked at by the person with the number c? If, for the specified a, b, and c, no such circle exists, output -1.
  
  Input
  
  The first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.
  
  Each test case consists of one line containing three distinct integers a, b, c (1 ≤ a,b,c ≤ 10^8).
  
  Output
  
  For each test case output in a separate line a single integer d — the number of the person being looked at by the person with the number c in a circle such that the person with the number a is looking at the person with the number b. If there are multiple solutions, print any of them. Output -1 if there's no circle meeting the given conditions.
  
  Example
  
  Input
  
  
  7
  6 2 4
  2 3 1
  2 4 10
  5 3 4
  1 3 2
  2 5 4
  4 3 2
  
  
  Output
  
  
  8
  -1
  -1
  -1
  4
  1
  -1
  
  Note
  
  In the first test case, there's a desired circle of 8 people. The person with the number 6 will look at the person with the number 2 and the person with the number 8 will look at the person with the number 4.
  
  In the second test case, there's no circle meeting the conditions. If the person with the number 2 is looking at the person with the number 3, the circle consists of 2 people because these persons are neighbors. But, in this case, they must have the numbers 1 and 2, but it doesn't meet the problem's conditions.
  
  In the third test case, the only circle with the persons with the numbers 2 and 4 looking at each other consists of 4 people. Therefore, the person with the number 10 doesn't occur in the circle.
solution: 
  /*
  
      /$$$$$  /$$$$$$  /$$    /$$  /$$$$$$                                                                  
     |__  $$ /$$__  $$ |$$    |$$ /$$__  $$                                                                 
            | $$| $$  \ $$|    $$|$$| $$  \ $$                                                                 
            | $$| $$$$$$$$|  $$ / $$/| $$$$$$$$                                                                 
  / $$  | $$| $$__  $$ \  $$ $$/ | $$__  $$                                                                 
  | $$  | $$| $$  | $$  \  $$$/  | $$  | $$                                                                 
  |  $$$$$$/| $$  | $$   \  $/   | $$  | $$                                                                 
   \______/ |__/  |__/    \_/    |__/  |__/                                                                 
  /$$$$$$$  /$$$$$$$   /$$$$$$   /$$$$$$  /$$$$$$$   /$$$$$$  /$$      /$$ /$$      /$$ /$$$$$$$$ /$$$$$$$ 
  | $$__  $$| $$__  $$ /$$__  $$ /$$__  $$| $$__  $$ /$$__  $$| $$$    /$$$| $$$    /$$$| $$_____/| $$__  $$
  | $$  \ $$| $$  \ $$| $$  \ $$| $$  \__/| $$  \ $$| $$  \ $$| $$$$  /$$$$| $$$$  /$$$$| $$      | $$  \ $$
  | $$$$$$$/| $$$$$$$/| $$  | $$| $$ /$$$$| $$$$$$$/| $$$$$$$$| $$ $$/$$ $$| $$ $$/$$ $$| $$$$$   | $$$$$$$/
  | $$____/ | $$__  $$| $$  | $$| $$|_  $$| $$__  $$| $$__  $$| $$  $$$| $$| $$  $$$| $$| $$__/   | $$__  $$
  | $$      | $$  \ $$| $$  | $$| $$  \ $$| $$  \ $$| $$  | $$| $$\  $ | $$| $$\  $ | $$| $$      | $$  \ $$
  | $$      | $$  | $$|  $$$$$$/|  $$$$$$/| $$  | $$| $$  | $$| $$ \/  | $$| $$ \/  | $$| $$$$$$$$| $$  | $$
  |__/      |__/  |__/ \______/  \______/ |__/  |__/|__/  |__/|__/     |__/|__/     |__/|________/|__/  |__/
  																																																				
  																																																				
  
  */
  
  import java.io.BufferedReader;
  import java.text.DecimalFormat;
  import java.text.ParseException;
  import java.text.SimpleDateFormat;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.math.BigInteger;
  import java.util.*;
  import java.util.stream.Collectors;
  import java.util.stream.Stream;
  import java.io.*;
  
  public class abc {
  	static PrintWriter pw;
  	/*
  	 * static long inv[]=new long[1000001]; static long dp[]=new long[1000001];
  	 */
  	/// MAIN FUNCTION///
  	public static void main(String[] args) throws Exception {
  
  		FastReader sc = new FastReader();
  		pw = new PrintWriter(System.out);
  		// use arraylist as it use the concept of dynamic table(amortized analysis)
  		// Arrays.stream(array).forEach(a -> Arrays.fill(a, 0));
  		/* List<Integer> l1 = new ArrayList<Integer>(); */
  		//Random rand = new Random();
  		int tst = sc.nextInt();
  		//pw.println(tst);
  		
  		while (tst-- > 0) {
  			int a=sc.nextInt();
  			int b=sc.nextInt();
  			int c=sc.nextInt();
  			int dif=Math.abs(a-b);
  			int max=Math.max(a, Math.max(b,c));
  			if(dif*2<max)
  				pw.println(-1);
  			else if(c>dif)
  				pw.println(c-dif);
  			else
  				pw.println(c+dif);
  		}
  		pw.flush();
  	}
  	
  	public static int helper(int a,int b,int c,int d)
  	{
  		List<Integer> l1 = new ArrayList<Integer>();
  		List<Integer> l2 = new ArrayList<Integer>();
  		int max=Math.max(a, Math.max(b, Math.max(c, d)));
  		int half=max%2==0?max/2:max/2+1;
  		for(int i=1;i<=half;i++)
  			l1.add(i);
  		for(int i=half+1;i<=(2*half);i++)
  			l2.add(i);
  		int f=-1;
  		//pw.println(l2);
  		if(l1.contains(a) && l2.contains(b))
  		{
  			//pw.println(a+" "+b+" "+c+" "+d);
  			if(l1.contains(c) && l2.contains(d))
  				f=1;
  			else if(l1.contains(d) && l2.contains(c))
  				f=1;
  		}
  		if(l1.contains(b) && l2.contains(a))
  		{
  			//pw.println(a+" "+b+" "+c+" "+d);
  			if(l1.contains(c) && l2.contains(d))
  				f=1;
  			if(l1.contains(d) && l2.contains(c))
  				f=1;
  		}
  		if(f==1)
  		return d;
  		else
  			return -1;
  	}
  	
  
  	public static void debugger() {
  		Random rand = new Random();
  		int tst = (int) (Math.abs(rand.nextInt()) % 2 + 1);
  		pw.println(tst);
  		while (tst-- > 0) {
  			int n = (int) (Math.abs(rand.nextInt()) % 5 + 1);
  			pw.println(n);
  			for (int i = 0; i < n; i++) {
  				pw.print((int) (Math.abs(rand.nextInt()) % 6 + 1) + " ");
  			}
  			pw.println();
  		}
  	}
  
  	static void recursion(int n) {
  		if (n == 1) {
  			pw.print(n + " ");
  			return;
  		}
  		// pw.print(n+" "); gives us n to 1
  		recursion(n - 1);
  		// pw.print(n+" "); gives us 1 to n
  	}
  
  	// ch.charAt(i)+"" converts into a char sequence
  	static class FastReader {
  		BufferedReader br;
  		StringTokenizer st;
  
  		public FastReader() {
  			br = new BufferedReader(new InputStreamReader(System.in));
  		}
  
  		String next() {
  			while (st == null || !st.hasMoreElements()) {
  				try {
  					st = new StringTokenizer(br.readLine());
  				} catch (IOException e) {
  					e.printStackTrace();
  				}
  			}
  			return st.nextToken();
  		}
  
  		int nextInt() {
  			return Integer.parseInt(next());
  		}
  
  		long nextLong() {
  			return Long.parseLong(next());
  		}
  
  		double nextDouble() {
  			return Double.parseDouble(next());
  		}
  
  		String nextLine() {
  			String str = "";
  			try {
  				str = br.readLine();
  			} catch (IOException e) {
  				e.printStackTrace();
  			}
  			return str;
  		}
  
  		/* CREATED BY ME */
  		int[] readArray(int n) {
  			int[] a = new int[n];
  			for (int i = 0; i < n; i++)
  				a[i] = nextInt();
  			return a;
  		}
  
  		long[] readLongArray(int n) {
  			long[] a = new long[n];
  			for (int i = 0; i < n; i++)
  				a[i] = nextLong();
  			return a;
  		}
  	}
  
  	public static long gcd(long a, long b) {
  		return b == 0 ? a : gcd(b, a % b);
  	}
  
  	public static boolean isPrime(long n) {
  		if (n == 2)
  			return true;
  		long i = 2;
  		while (i * i <= n) {
  			if (n % i == 0)
  				return false;
  			i++;
  		}
  		return true;
  	}
  
  	static int ceil(int x, int y) {
  		return (x % y == 0 ? x / y : (x / y + 1));
  	}
  
  	static long ceil(long x, long y) {
  		return (x % y == 0 ? x / y : (x / y + 1));
  	}
  
  	static double max(double x, double y) {
  		return Math.max(x, y);
  	}
  
  	static int min(int x, int y) {
  		return Math.min(x, y);
  	}
  
  	static int abs(int x) {
  		return Math.abs(x);
  	}
  
  	static long abs(long x) {
  		return Math.abs(x);
  	}
  
  	static int log2(int N) {
  		int result = (int) (Math.log(N) / Math.log(2));
  		return result;
  	}
  
  	static long max(long x, long y) {
  		return Math.max(x, y);
  	}
  
  	static long min(long x, long y) {
  		return Math.min(x, y);
  	}
  
  	public static class pair {
  		long x;
  		long y;
  		public pair(long a, long b) {
  			x = a;
  			y = b;
  		}
  	}
  
  	public static class Comp implements Comparator<pair> {
  		public int compare(pair a, pair b) {
  			long ans = a.x - b.x;
  			if (ans > 0)
  				return 1;
  			if (ans < 0)
  				return -1;
  			return 0;
  		}
  	}
  
  	// modular exponentiation
  	public static long fastExpo(long a, int n, int mod) {
  		if (n == 0)
  			return 1;
  		else {
  			if ((n & 1) == 1) {
  				long x = fastExpo(a, n / 2, mod);
  				return (((a * x) % mod) * x) % mod;
  			} else {
  				long x = fastExpo(a, n / 2, mod);
  				return (((x % mod) * (x % mod)) % mod) % mod;
  			}
  		}
  	}
  
  	public static long modInverse(long n, int p) {
  		return fastExpo(n, p - 2, p);
  	}
  
  	/*
  	 * public static void extract(ArrayList<Integer> ar, int k, int d) { int c = 0;
  	 * for (int i = 1; i < k; i++) { int x = 0; boolean dm = false; while (x > 0) {
  	 * long dig = x % 10; x = x / 10; if (dig == d) { dm = true; break; } } if (dm)
  	 * ar.add(i); } }
  	 */
  
  	public static int[] prefixfuntion(String s) {
  		int n = s.length();
  		int z[] = new int[n];
  		for (int i = 1; i < n; i++) {
  			int j = z[i - 1];
  			while (j > 0 && s.charAt(i) != s.charAt(j))
  				j = z[j - 1];
  			if (s.charAt(i) == s.charAt(j))
  				j++;
  			z[i] = j;
  		}
  		return z;
  	}
  
  	public static void dfs(int index, boolean vis[], int a[], int b[], int n) {
  		vis[index] = true;
  		for (int i = 0; i < n; i++) {
  			if (!vis[i] && (a[i] == a[index] || b[i] == b[index]))
  				dfs(i, vis, a, b, n);
  		}
  	}
  
  // counts the set(1) bit of a number
  	public static long countSetBitsUtil(long x) {
  		if (x <= 0)
  			return 0;
  		return (x % 2 == 0 ? 0 : 1) + countSetBitsUtil(x / 2);
  	}
  
  //tells whether a particular index has which bit of a number	
  	public static int getIthBitsUtil(int x, int y) {
  		return (x & (1 << y)) != 0 ? 1 : 0;
  	}
  
  	public static void swaper(long x, long y) {
  		x = x ^ y;
  		y = y ^ x;
  		x = x ^ y;
  	}
  
  	/*
  	 * static long mod_inverse(long a, long b) { long mod=(long) (1000000007); long
  	 * ans=1; while(b>0) { if((b%2)==0) ans=(ans*a) %mod; b/=2; a=(a*a) % mod;
  	 * 
  	 * } return ans; }
  	 */
  
  	public static double decimalPlaces(double sum) {
  		DecimalFormat df = new DecimalFormat("#.00");
  		String angleFormated = df.format(sum);
  		double fin = Double.parseDouble(angleFormated);
  		return fin;
  	}
  
  //use collections.swap for swapping 
  	static boolean isSubSequence(String str1, String str2, int m, int n) {
  		int j = 0;
  
  		for (int i = 0; i < n && j < m; i++)
  			if (str1.charAt(j) == str2.charAt(i))
  				j++;
  
  		return (j == m);
  	}
  
  	static long sum(long n) {
  		long s2 = 0, max = -1, min = 10;
  		while (n > 0) {
  			s2 = (n % 10);
  			min = min(s2, min);
  			max = max(s2, max);
  			n = n / 10;
  		}
  		return max * min;
  	}
  
  	static long pow(long base, long power) {
  		if (power == 0) {
  			return 1;
  		}
  		long result = pow(base, power / 2);
  		if (power % 2 == 1) {
  			return result * result * base;
  		}
  		return result * result;
  	}
  
  	// return the hash value of a string
  	static long compute_hash(String s) {
  		long val = 0;
  		long p = 31;
  		long mod = (long) (1000000007);
  		long pow = 1;
  		for (int i = 0; i < s.length(); i++) {
  			char ch = s.charAt(i);
  			val = (val + (int) (ch - 'a' + 1) * pow) % mod;
  			pow = (pow * p) % mod;
  		}
  		return val;
  	}
  
  	// return a prefix sum array of hash values
  	/*
  	 * static void prefix_array_value(String s) { long p=31; long mod=(long)
  	 * (1000000007); long pow=1; inv[0]=1; dp[0]=(long)(s.charAt(0)-'a'+1);
  	 * 
  	 * for(int i=1;i<s.length();i++) { char ch=s.charAt(i); pow= ( pow*p ) % mod;
  	 * inv[i]=mod_inverse(pow, mod-2); dp[i]=(dp[i-1]+ (long)(ch- 'a' +1)*pow)%mod;
  	 * } }
  	 */
  
  	/*
  	 * static long substringHash(int L , int R ) { long result = dp[R]; long
  	 * mod=(long) (1000000007); if(L > 0) result = (result - dp[L-1] + mod) % mod;
  	 * result= (result * inv[L]) % mod; return result; }
  	 */
  }
  