import java.io.*;
import java.util.*;

public class Most {
  public static void main(String args[]) throws Exception {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String line;
    int N = Integer.parseInt(in.readLine());
    for(int i = 0; i < N; i++) {
	int M = Integer.parseInt(in.readLine());

	int X = 1100000;
	int LM = -1100000;
	int RM = 1100000;

	for(int j = 0; j < M; j++){
		String[] st = in.readLine().split(" ");
		int A = Integer.parseInt(st[0]);
		int B = Integer.parseInt(st[1]);

		LM = Math.max(LM - 1, A);
		RM = Math.min(RM + 1, B);

		X = Math.min(X, B-LM);
		X = Math.min(X, RM-A);
	}

	System.out.printf("K prechodu reky je treba %d pontonu.\n", X);
	
    }
  }
}
