import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Solution_D3_3431_준환이의운동관리 {
static int T, Answer;
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//br = new BufferedReader(new StringReader(src));
T = Integer.parseInt(br.readLine());
for(int t=1; t<=T; t++) {
Answer = 0;
StringTokenizer tokens = new StringTokenizer(br.readLine());
while(tokens.hasMoreTokens()) {
int L = Integer.parseInt(tokens.nextToken());
int U = Integer.parseInt(tokens.nextToken());
int X = Integer.parseInt(tokens.nextToken());
if(X < L) {
Answer = L-X;
}else if(X > U) {
Answer = -1;
}
}
System.out.printf("#%d %d\n", t, Answer);
}
}
static String src="3\r\n" +
"300 400 240\r\n" +
"300 400 350\r\n" +
"300 400 480";
}