#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
  long long temp = a * b;
  temp /= gcd(max(a, b), min(a, b));
  return temp;
}
void swap(int *a, int *b) {
  int temp = *a;
  *a = *b;
  *b = temp;
}
int bsearch(long long arr[], long long req, int n) {
  sort(arr, arr + n);
  int start = 0, end = n - 1;
  while (start <= end) {
    int temp = start + end;
    temp /= 2;
    if (arr[temp] > req) end = temp - 1;
    if (arr[temp] < req) start = temp + 1;
    if (arr[temp] == req) return temp;
  }
  return -1;
}
long long fastpower(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) {
      res = res * a;
    }
    b /= 2;
    a = a * a;
  }
  return res;
}
void solveTestCase() {
  int a;
  cin >> a;
  ;
  int b;
  cin >> b;
  ;
  int c;
  cin >> c;
  ;
  int diff = abs(a - b);
  int maxi = diff * 2;
  int mini = 1;
  if (max(a, b) > maxi) {
    cout << -1 << "\n";
    return;
  }
  if (min(a, b) == 1) mini++;
  if (max(a, b) == maxi) maxi--;
  if (c > maxi || c < mini) {
    cout << -1 << "\n";
    return;
  }
  if (c + diff <= maxi)
    cout << c + diff << "\n";
  else if (c - diff >= mini)
    cout << c - diff << "\n";
  else
    cout << -1 << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int tests = 1;
  cin >> tests;
  bool google = false;
  int k = 1;
  while (tests--) {
    if (google) cout << "Case #" << k << ": ";
    solveTestCase();
    k++;
  }
  return 0;
}
