import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; /** * * @author kuric10 */ public class Most { private static int pocTC,row,min, akt, temp, pom,rozdiel; private static int pole[][] = new int[1000002][2]; /** * @param args the command line arguments */ public static void main(String[] args)throws IOException{ // TODO code application logic here BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); // Scanner input = new Scanner(System.in); String s,poleS[]; pocTC = Integer.parseInt(input.readLine()); // pocTC = input.nextInt(); for (int i = 0; i < pocTC; i++) { row = Integer.parseInt(input.readLine()); // row = input.nextInt(); min = 1000000; for (int j = 0; j < row; j++) { poleS = input.readLine().split(" "); pole[j][0] = Integer.parseInt(poleS[0]); pole[j][1] = Integer.parseInt(poleS[1]); // pole[j][0] = input.nextInt(); // pole[j][1] = input.nextInt(); rozdiel = pole[j][1]-pole[j][0]; if(min>rozdiel){ min = rozdiel; } } for (int j = 0; j < row; j++) { //hore for (int k = j-1; k >=Math.max(0, j-min-1); k--) { temp = j-k;//+Math.abs(pole[j][0]-pole[k][1]); if(pole[j][0]