#include <bits/stdc++.h>
using namespace std;
const unsigned long long mode = 1000000007;
long long T, n;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> T;
  while (T--) {
    int a, b, c;
    cin >> a >> b >> c;
    if (b > a) {
      int temp = a;
      a = b;
      b = temp;
    }
    int ban = a - b;
    int up = ban * 2;
    if (a > up || b > up) {
      cout << "-1" << endl;
      continue;
    }
    if (c > up) {
      cout << "-1" << endl;
      continue;
    }
    if (c - ban > 0) {
      cout << c - ban << endl;
    } else if (c + ban <= up) {
      cout << c + ban << endl;
    } else {
      cout << "-1" << endl;
    }
  }
  return 0;
}
