#include <bits/stdc++.h>
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    int n = a > b ? (a - b) * 2 : (b - a) * 2;
    if (c > n || a > n || b > n)
      printf("-1\n");
    else
      printf("%d\n", c > n / 2 ? (c - n / 2) : (n / 2 + c));
  }
}
