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.lang.reflect.Array;
  // import java.math.BigInteger;
  // import java.nio.channels.AcceptPendingException;
  // import java.nio.charset.IllegalCharsetNameException;
  // import java.util.Collections;
  // import java.util.logging.SimpleFormatter;
  // import java.util.regex.Matcher;
  // import java.util.regex.Pattern;
  
  import java.util.*;
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.io.*;
  
  /* docstring*/
  public class Main {
      static Templates.FastScanner sc = new Templates.FastScanner();
      static PrintWriter fop = new PrintWriter(System.out);
  
      public static void main(String[] args) {
          try {
              // DislikeofThrees();
              WhoOpposite();
              // C();
              // D();
              // E();
          } catch (Exception e) {
              return;
          }
      }
  
      /* docstring */
      static void DislikeofThrees() throws IOException {
          int T = Integer.parseInt(sc.next());
          while (T-- > 0) {
              // Write Your Code...
              int k = sc.nextInt();
              int count = 0;
              int element = 0;
              while (element != k) {
                  count++;
                  if (count % 3 != 0 && count % 10 != 3)
                      element++;
              }
              System.out.println(count);
  
          }
          fop.flush();
          fop.close();
  
      }
  
  
      /* docstring */
      static void WhoOpposite() throws IOException {
          int T = Integer.parseInt(sc.next());
          while (T-- > 0) {
              // Write Your Code...
              int a = sc.nextInt();
              int b = sc.nextInt();
              int c = sc.nextInt();
              int flag = 0;
              if( Math.abs(a - b) == 1){
                  flag = 1;
              }
              int max = Math.abs(a - b)*2;
              if( max < c){
                  flag = 1;
              }
              if(a > max || b > max){
                  flag = 1;
              }
  
              if(flag == 1){
                  System.out.println(-1);
              }
              else{
                  if( Math.abs(a - b) >= c){
                      System.out.println( Math.abs(a - b)+c );
                  }
                  else{
                      System.out.println( c-Math.abs(a - b) );
                  }
              }
  
          }
          fop.flush();
          fop.close();
      }
  
      /* docstring */
      static void C() throws IOException {
          int T = Integer.parseInt(sc.next());
          while (T-- > 0) {
              // Write Your Code...
          }
          fop.flush();
          fop.close();
      }
  
      /* docstring */
      static void D() throws IOException {
          int T = Integer.parseInt(sc.next());
          while (T-- > 0) {
              // Write Your Code...
          }
          fop.flush();
          fop.close();
      }
  
      /* docstring */
      static void E() throws IOException {
          int T = Integer.parseInt(sc.next());
          while (T-- > 0) {
              // Write Your Code...
          }
          fop.flush();
          fop.close();
      }
  }
  
  class Templates {
  
      // int tree[] = new int[4*n+1] ;
      // BuiltTree(A , 0 , n-1 , tree , 1);
      // int lazy[] = new int[4*n + 1] ;
      //
      // updateRangeLazy(tree , lazy , 0 , n-1 , 0 , 2 , 10 , 1);
      // updateRangeLazy(tree , lazy , 0 , n-1 , 0 , 4 , 10 , 1);
      //
      // fop.println(querylazy(tree , lazy , 0 , n-1 , 1 ,1 ,1));
      //
      // updateRangeLazy(tree, lazy , 0 , n-1 , 10 , 4 , 3 ,1);
      // fop.println(querylazy(tree , lazy , 0 , n-1 , 3 , 5 , 1 ));
  
      static class FastScanner {
          BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
          StringTokenizer st = new StringTokenizer("");
  
          String next() {
              while (!st.hasMoreTokens())
                  try {
                      st = new StringTokenizer(br.readLine());
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              return st.nextToken();
          }
  
          int nextInt() {
              return Integer.parseInt(next());
          }
  
          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;
          }
  
          long nextLong() {
              return Long.parseLong(next());
          }
      }
      // segment tree
  
      // BuiltTree(A , 0 , n-1 , tree , 1);
      static void BuiltTree(int A[], int s, int e, int tree[], int index) {
          if (s == e) {
              tree[index] = A[s];
              return;
          }
  
          int mid = (s + e) / 2;
          BuiltTree(A, s, mid, tree, 2 * index);
          BuiltTree(A, mid + 1, e, tree, 2 * index + 1);
          tree[index] = Math.min(tree[2 * index], tree[2 * index + 1]);
          return;
  
      }
  
      static int query(int tree[], int ss, int se, int qs, int qe, int index) {
  
          // complete overlap
          if (ss >= qs && se <= qe)
              return tree[index];
  
          // no overlap
          if (qe < ss || qs > se)
              return Integer.MAX_VALUE;
  
          // partial overlap
          int mid = (ss + se) / 2;
          int left = query(tree, ss, mid, qs, qe, 2 * index);
          int right = query(tree, mid + 1, se, qs, qe, 2 * index + 1);
          return Math.min(left, right);
      }
  
      static void update(int tree[], int ss, int se, int i, int increment, int index) {
          // i is the index of which we want to update the value
  
          if (i > se || i < ss)
              return;
  
          if (ss == se) {
              tree[index] += increment;
              return;
          }
          int mid = (ss + se) / 2;
          update(tree, ss, mid, i, increment, 2 * index);
          update(tree, mid + 1, se, i, increment, 2 * index + 1);
          tree[index] = Math.min(tree[2 * index], tree[2 * index + 1]);
  
      }
  
      static void updateRange(int tree[], int ss, int se, int l, int r, int inc, int index) {
  
          if (l > se || r < ss)
              return;
  
          if (ss == se) {
              tree[index] += inc;
              return;
          }
  
          int mid = (ss + se) / 2;
          updateRange(tree, ss, mid, l, r, inc, 2 * index);
          updateRange(tree, mid + 1, se, l, r, inc, 2 * index + 1);
  
          tree[index] = Math.min(tree[2 * index], tree[2 * index + 1]);
          return;
  
      }
      // Lazy rnage Update
  
      static void updateRangeLazy(int tree[], int lazy[], int ss, int se, int l, int r, int increment, int index) {
  
          if (lazy[index] != 0) {
              tree[index] += lazy[index];
  
              if (ss != se) {
                  lazy[2 * index] += lazy[index];
                  lazy[2 * index + 1] += lazy[index];
              }
              lazy[index] = 0;
          }
  
          if (ss > r && se < l)
              return;
  
          if (ss >= l && se <= r) {
              tree[index] += increment;
  
              if (ss != se) {
                  lazy[2 * index] += increment;
                  lazy[2 * index + 1] += increment;
              }
              return;
          }
  
          int mid = (ss + se) / 2;
          updateRange(tree, ss, mid, l, r, increment, 2 * index);
          updateRange(tree, mid + 1, se, l, r, increment, 2 * index + 1);
  
          tree[index] = Math.min(tree[2 * index], tree[2 * index + 1]);
  
      }
  
      // min lazy query
  
      static int querylazy(int tree[], int lazy[], int ss, int se, int qs, int qe, int index) {
  
          if (lazy[index] != 0) {
  
              tree[index] += lazy[index];
              if (ss != se) {
                  lazy[2 * index] += lazy[index];
                  lazy[2 * index + 1] += lazy[index];
              }
              lazy[index] = 0;
          }
  
          if (ss > qe || se < qs)
              return Integer.MAX_VALUE;
  
          if (ss >= qs && se <= qe)
              return tree[index];
  
          int mid = (ss + se) / 2;
          int left = querylazy(tree, lazy, ss, mid, qs, qe, 2 * index);
          int right = querylazy(tree, lazy, mid + 1, se, qs, qe, 2 * index + 1);
  
          return Math.min(left, right);
  
      }
  
      static void sieve(int n) {
          boolean[] flag = new boolean[n];
  
          for (int i = 2; i * i < n; i++) {
              if (flag[i])
                  continue;
              else
                  for (int j = i * i; j <= n; j += i) {
                      flag[j] = true;
                  }
          }
  
      }
  
      static int gcd(int a, int b) {
          if (b > a) {
              int tenp = b;
              b = a;
              a = tenp;
          }
          int temp = 0;
          while (b != 0) {
              a %= b;
              temp = b;
              b = a;
              a = temp;
          }
          return a;
      }
  
      static long gcdl(long a, long b) {
          if (b > a) {
              long tenp = b;
              b = a;
              a = tenp;
          }
          long temp = 0;
          while (b != 0) {
              a %= b;
              temp = b;
              b = a;
              a = temp;
          }
          return a;
      }
  
      static final Random random = new Random();
  
      static void ruffleSort(int[] a) {
          int n = a.length;// shuffle, then sort
          for (int i = 0; i < n; i++) {
              int oi = random.nextInt(n), temp = a[oi];
              a[oi] = a[i];
              a[i] = temp;
          }
          Arrays.sort(a);
      }
  }
  