import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); for (int i = 0; i < t; i++) { String[] sa = br.readLine().split(" "); long a = Integer.parseInt(sa[0]); long b = Integer.parseInt(sa[1]); long c = Integer.parseInt(sa[2]); long ans = Long.MAX_VALUE; if (b > a) { if (b == c) { ans = 1; c--; if (a == c) { if (a == 1) { ans = -1; } else { ans++; } } } else if (b > c) { if (a == c) { if (a == 1) { ans = -1; } else { ans = 1; } } else { ans = 0; } } else { if (c - b < b - a || a == 1) { ans = c - b + 1; c = b - 1; if (a == c) { if (a == 1) { ans = -1; } else { ans++; } } } else { ans = b - a + 1; } } } else if (b == a) { if (b == c) { if (a <= 2) { ans = -1; } else { ans = 3; } } else if (b == c + 1) { if (c == 1) { ans = -1; } else { ans = 2; } } else { if (a == 1) { ans = -1; } else { ans = 1; } } } else { // a > b if (b == c) { if (c == 1) { ans = -1; } else { ans = 1; } } else if (b > c) { if (a - b < b - c || c == 1) { ans = a - b + 1; a = b - 1; if (a == c) { if (c == 1) { ans = -1; } else { ans++; } } } else { ans = b - c + 1; } } else { if (a == c) { if (a == 2 && b == 1) { ans = -1; } else { ans = 1; } } else { ans = 0; } } } System.out.println(ans); } br.close(); } }