#include <bits/stdc++.h>
using namespace std;
int ans(int a, int b, int c) {
  int diff = abs(a - b);
  int circleOf = 2 * diff;
  if (diff == 1) return -1;
  if (c > circleOf || c < 1) return -1;
  if (max(a, b) > circleOf) return -1;
  if (c > diff) return c - diff;
  return c + diff;
}
int main() {
  int nt;
  cin >> nt;
  while (nt--) {
    int a, b, c;
    cin >> a;
    cin >> b;
    cin >> c;
    cout << ans(a, b, c) << endl;
  }
  return 0;
}
