description: Alice and Bob play the following game. Alice has a set S of disjoint ranges of integers, initially containing only one range [1, n]. In one turn, Alice picks a range [l, r] from the set S and asks Bob to pick a number in the range. Bob chooses a number d (l ≤ d ≤ r). Then Alice removes [l, r] from S and puts into the set S the range [l, d - 1] (if l ≤ d - 1) and the range [d + 1, r] (if d + 1 ≤ r). The game ends when the set S is empty. We can show that the number of turns in each game is exactly n.
  
  After playing the game, Alice remembers all the ranges [l, r] she picked from the set S, but Bob does not remember any of the numbers that he picked. But Bob is smart, and he knows he can find out his numbers d from Alice's ranges, and so he asks you for help with your programming skill.
  
  Given the list of ranges that Alice has picked ([l, r]), for each range, help Bob find the number d that Bob has picked.
  
  We can show that there is always a unique way for Bob to choose his number for a list of valid ranges picked by Alice.
  
  Input
  
  Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 1000). Description of the test cases follows.
  
  The first line of each test case contains a single integer n (1 ≤ n ≤ 1000).
  
  Each of the next n lines contains two integers l and r (1 ≤ l ≤ r ≤ n), denoting the range [l, r] that Alice picked at some point.
  
  Note that the ranges are given in no particular order.
  
  It is guaranteed that the sum of n over all test cases does not exceed 1000, and the ranges for each test case are from a valid game.
  
  Output
  
  For each test case print n lines. Each line should contain three integers l, r, and d, denoting that for Alice's range [l, r] Bob picked the number d.
  
  You can print the lines in any order. We can show that the answer is unique.
  
  It is not required to print a new line after each test case. The new lines in the output of the example are for readability only. 
  
  Example
  
  Input
  
  
  4
  1
  1 1
  3
  1 3
  2 3
  2 2
  6
  1 1
  3 5
  4 4
  3 6
  4 5
  1 6
  5
  1 5
  1 2
  4 5
  2 2
  4 4
  
  
  Output
  
  
  1 1 1
  
  1 3 1
  2 2 2
  2 3 3
  
  1 1 1
  3 5 3
  4 4 4
  3 6 6
  4 5 5
  1 6 2
  
  1 5 3
  1 2 1
  4 5 5
  2 2 2
  4 4 4
  
  Note
  
  In the first test case, there is only 1 range [1, 1]. There was only one range [1, 1] for Alice to pick, and there was only one number 1 for Bob to pick.
  
  In the second test case, n = 3. Initially, the set contains only one range [1, 3]. 
  
    * Alice picked the range [1, 3]. Bob picked the number 1. Then Alice put the range [2, 3] back to the set, which after this turn is the only range in the set. 
    * Alice picked the range [2, 3]. Bob picked the number 3. Then Alice put the range [2, 2] back to the set. 
    * Alice picked the range [2, 2]. Bob picked the number 2. The game ended. 
  
  
  
  In the fourth test case, the game was played with n = 5. Initially, the set contains only one range [1, 5]. The game's turn is described in the following table. 
  
  Game turn| Alice's picked range| Bob's picked number| The range set after  
  ---|---|---|---  
  Before the game start| | |  \{ [1, 5] \}   
  1| [1, 5]| 3|  \{ [1, 2], [4, 5] \}  
  2| [1, 2]| 1|  \{ [2, 2], [4, 5] \}   
  3| [4, 5]| 5|  \{ [2, 2], [4, 4] \}   
  4| [2, 2]| 2|  \{ [4, 4] \}   
  5| [4, 4]| 4|  \{ \}  (empty set)
solution: 
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.io.OutputStreamWriter;
  import java.io.PrintWriter;
  import java.util.Collections;
  import java.util.HashMap;
  import java.util.Map;
  import java.util.StringTokenizer;
  import java.util.TreeSet;
  import java.util.Vector;
  
  public class B_Game_on_Ranges {
  
      static Scanner in=new Scanner();
      
      static PrintWriter out=new PrintWriter( new OutputStreamWriter(System.out) );
      
      static int testCases,n,l[],r[];
      
      static void solve()
      {
          
          Vector<pairElement> a=new Vector<>();
          
          Map<Integer,Integer> countA=new HashMap<>();
          
       //   Map<Integer,Integer> countB=new HashMap<>();
          
          for(int i=0;i<n;i++){
              
              a.add(new pairElement(l[i],r[i]) );
              
              countA.put(l[i], countA.getOrDefault(l[i], 0)+1 );
              
              countA.put(r[i], countA.getOrDefault(r[i], 0)+1 );
              
          }
          
          Collections.sort(a);
          
          TreeSet<Integer> set=new TreeSet<>();
          
          for(int i=1;i<=n;i++){
              
              set.add(i);
              
          }
          
          for(pairElement i: a){
              
              int ans=set.ceiling(i.left);
              
              set.remove(ans);
              
              i.ans=ans;
              
          }
        
          for(pairElement i: a){
              
              out.println(i.left+" "+i.right+" "+i.ans);
              out.flush();
              
          }
          
          out.println();
          out.flush();
          
      }        
      
      public static void main(String[] amit) throws IOException {
          
          testCases=in.nextInt();
          
          for(int t=0;t<testCases;t++){
              
              n=in.nextInt();
             
              l=new int[n];
              r=new int[n];
              
              for(int i=0;i<n;i++){
                  
                  l[i]=in.nextInt();
                  r[i]=in.nextInt();
                  
              }
              
              solve();
              
          }
          
      }
       
      static class pairElement implements Comparable<pairElement> {
          
          int left,right,ans;
  
          public pairElement(int left, int right) {
              this.left = left;
              this.right = right;
          }
  
          @Override
          public int compareTo(pairElement t) {
          //    throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
          
          /*if(this.left-this.right==t.left-t.right ){
              
              return Integer.compare(this.left, t.left);
              
          }*/
          
            return Integer.compare(-this.left+this.right+1, -t.left+t.right+1);
          
          }
          
      }
      
      static String sum(String a,String b){
          
          StringBuilder ans=new StringBuilder();
          
          int n1=a.length(),m=b.length();
          
          if(n1>m ){
              
              String t=a;
              a=b;
              b=t;
              
          }
          
          n1=a.length();
          m=b.length();
          
          StringBuilder str1=new StringBuilder(a).reverse();
          StringBuilder str2=new StringBuilder(b).reverse();
          
          char first[]=str1.toString().toCharArray();
          char second[]=str2.toString().toCharArray();
          
          int carry=0;
          
          for(int i=0;i<n1;i++){
              
              int sum=(first[i]-'0')+(second[i]-'0')+carry;
              
              ans.append(sum%10 );
              
              carry=sum/10;
              
          }
          
          for(int i=n1;i<m;i++){
              
             int sum=(second[i]-'0')+carry;
             
             ans.append(sum%10 );
              
             sum/=10;
             
          }
          
          if(carry>0){
              
              ans.append(carry);
              
          }
          
          ans.reverse();
          
          return ans.toString();
          
      }
      
      static String mul(String num1, String num2)
  {
      int len1 = num1.length();
      int len2 = num2.length();
      if (len1 == 0 || len2 == 0)
          return "0";
   
      
      int result[] = new int[len1 + len2];
   
      
      int i_n1 = 0;
      int i_n2 = 0;
       
    
      for (int i = len1 - 1; i >= 0; i--)
      {
          int carry = 0;
          int n1 = num1.charAt(i) - '0';
   
          
          i_n2 = 0;
           
                   
          for (int j = len2 - 1; j >= 0; j--)
          {
              
              int n2 = num2.charAt(j) - '0';
   
             
              int sum = n1 * n2 + result[i_n1 + i_n2] + carry;
   
              
              carry = sum / 10;
   
           
              result[i_n1 + i_n2] = sum % 10;
   
              i_n2++;
          }
   
         
          if (carry > 0)
              result[i_n1 + i_n2] += carry;
   
         
          i_n1++;
      }
   
     
      int i = result.length - 1;
      while (i >= 0 && result[i] == 0)
      i--;
   
     
      if (i == -1)
      return "0";
   
      
      String s = "";
       
      while (i >= 0)
          s += (result[i--]);
   
      return s;
  }
      
      static int multiply(int x, int res[], int res_size) {
   
      
      int carry = 0;
   
      
      for (int i = 0; i < res_size; i++) {
      int prod = res[i] * x + carry;
   
      
      res[i] = prod % 10;
   
     
      carry = prod / 10;
      }
   
     
      while (carry > 0) {
      res[res_size] = carry % 10;
      carry = carry / 10;
      res_size++;
      }
      return res_size;
  }
   
  
  static long power(int x, int n) {
       
      int MAX = 100000;
      
      
      if(n == 0 ){
     
          
      return 1;
  }
      int res[] = new int[MAX];
      int res_size = 0;
      int temp = x;
   
     
      while (temp != 0) {
      res[res_size++] = temp % 10;
      temp = temp / 10;
      }
   
      
      for (int i = 2; i <= n; i++)
      res_size = multiply(x, res, res_size);
   
     StringBuilder sb=new StringBuilder();
      
      for (int i = res_size - 1; i >= 0; i--)
      sb.append(res[i]);
      
      return Long.parseLong(sb.toString());
      
  }
                    
     static class Node<T>{
      
      T data;
      
      Node<T> next;
  
      public Node() {
      
          this.next=null;
      
      }
  
      public Node(T data) {
          
          this.data = data;
      
          this.next=null;
          
      }
  
      public T getData() {
          return data;
      }
  
      public void setData(T data) {
          this.data = data;
      }
  
      public Node<T> getNext() {
          return next;
      }
  
      public void setNext(Node<T> next) {
          this.next = next;
      }
      
      @Override
      public String toString(){
          
          return this.getData().toString()+"  ";
          
      }
      
  }
  
     static class ArrayList<T>{
             
      Node<T> head,tail;
      
      int len;
  
      public ArrayList() {
      
      this.head=null;    
          
      this.tail=null;
      
      this.len=0;
      
      }
      
      int size(){
          
          return len;
          
      }
      
      boolean isEmpty(){
          
          return len==0;
          
      }
      
      int indexOf(T data){
          
          if( isEmpty() ){
              
              throw new ArrayIndexOutOfBoundsException();
              
          }
          
          Node<T> temp=head;
          
          int index=0,i=0;
          
          while(temp!=null){
              
              if( temp.getData()==data ){
                  
                  index=i;
                  
              }
              
              i++;
              
              temp=temp.getNext();
              
          }
          
          return index;
          
      }
      
      void add(T data){
          
          Node<T> newNode=new Node<>(data);
          
          if( isEmpty() ){
              
              head=newNode;
              
              tail=newNode;
              
              len++;
              
          }else{
          
          tail.setNext(newNode);
              
          tail=newNode;
          
          len++;
          
          }
          
      }
      
      void see(){
          
          if( isEmpty() ){
              
              throw new ArrayIndexOutOfBoundsException();
              
          }
          
          Node<T> temp=head;
          
          while( temp!=null ){
              
              out.print(temp.getData().toString()+" ");
              out.flush();
              
              temp=temp.getNext();
              
          }
          
          out.println();
          out.flush();
          
      }
              
      void inserFirst(T data){
          
          Node<T> newNode=new Node<>(data);
          
          Node<T> temp=head;
          
          if( isEmpty() ){
              
              head=newNode;
              tail=newNode;
              
              len++;
              
          }else{
              
              newNode.setNext(temp);
              
              head=newNode;
              
              len++;
              
          }
          
      }
      
      T get(int index){
          
          if( isEmpty() || index>=len ){
              
              throw new ArrayIndexOutOfBoundsException();
              
          }
          
          Node<T> temp=head;
          
          if(index==0){
              
              return temp.getData();
              
          }
          
          int i=0;
          
          T data=null;
          
          while(temp!=null){
              
              if( i==index ){
                  
                  data=temp.getData();
                  
              }
              
              i++;
              
              temp=temp.getNext();
              
          }
          
          return data;
          
      }
      
      void addAt(T data,int index){
          
          if( index>=len ){
              
              throw new ArrayIndexOutOfBoundsException();
              
          }
          
          Node<T> newNode=new Node<>(data);
          
          int i=0;
          
          Node<T> temp=head;
          
          while( temp.next!=null ){
              
              if(i==index){
                  
                  newNode.setNext(temp.next);
                  
                  temp.next=newNode;
                  
              }
              
              i++;
              
              temp=temp.getNext();
              
          }
          
      //    temp.setNext(temp);
          
          len++;
          
      }
      
      T popFront(){
          
          if( isEmpty() ){
              
              throw new ArrayIndexOutOfBoundsException();
              
          }
          
          T data=head.getData();
          
          if( head==tail ){
              
              head=null;
              tail=null;
              
          }else{
              
              head=head.getNext();
              
          }
          
          len--;
          
          return data;
          
      }
      
      void removeAt(int index){
          
          if( index>=len ){
              
              throw new ArrayIndexOutOfBoundsException();
              
          }
          
          if(index==0){
              
              this.popFront();
              
              return;
              
          }
          
          Node<T> temp=head;
          
          int i=0;
          
          Node<T> n=new Node<>();
          
          while(temp!=null){
              
              if(i==index){
                  
                  n.next=temp.next;
                  
                  temp.next=n;
                  
                  break;
                  
              }
              
              i++;
              
              n=temp;
              
              temp=temp.getNext();
              
          }
          
          tail=n;
          
          --len;
          
      }
      
      void clearAll(){
          
          this.head=null;
          this.tail=null;
          
      }
         
     }
     
      static long gcd(long a, long b)
      {
        if (b == 0)
          return a;
        return gcd(b, a % b);
      }
  	
     static void merge(long a[],int left,int right,int mid){
          
          int n1=mid-left+1,n2=right-mid;
          
          long L[]=new long[n1];
          
          long R[]=new long[n2];
          
          for(int i=0;i<n1;i++){
              
              L[i]=a[left+i];
              
          }
          
          for(int i=0;i<n2;i++){
              
              R[i]=a[mid+1+i];
              
          }
          
          int i=0,j=0,k1=left;
          
          while(i<n1 && j<n2){
              
              if( L[i]<=R[j] ){
                  
                  a[k1]=L[i];
                  
                  i++;
                  
              }else{
                  
                  a[k1]=R[j];
                  
                  j++;
                  
              }
              
              k1++;
              
          }
          
          while(i<n1){
              
              a[k1]=L[i];
              
              i++;
              
              k1++;
              
          }
          
          while(j<n2){
              
              a[k1]=R[j];
              
              j++;
              k1++;
              
          }
          
      }
      
      static void sort(long a[],int left,int right){
          
          if(left>=right){
              
              return;
              
          }
          
          int mid=(left+right)/2;
          
          sort(a,left,mid);
          
          sort(a,mid+1,right);
          
          merge(a,left,right,mid);
          
      }
  	
      static class Node1<T>{
          
          T data;
          
          Node1 next;
  
          public Node1(T data) {
              this.data = data;
          
              this.next=null;
              
          }
  
          public T getData() {
              return data;
          }
  
          public void setData(T data) {
              this.data = data;
          }
  
          public Node1 getNext() {
              return next;
          }
  
          public void setNext(Node1 next) {
              this.next = next;
          }
          
      }
      
      static class Stack<T>{
          
          int len;
          
          Node1<T> node;
  
          public Stack() {
          
              len=0;
              
              node=null;
              
          }
          
          boolean isEmpty(){
              
              return len==0;
              
          }
          
          int size(){
              
              return len;
              
          }
          
          void push(T data){
              
              Node1<T> temp=new Node1<>(data);
              
              temp.setNext(this.node);
              
              node=temp;
              
              len++;
              
          }
          
          T top(){
              
              if( isEmpty() ){
                  
                  throw new ArrayIndexOutOfBoundsException();
                  
              }
              
              return this.node.getData();
              
          }
          
          T pop(){
              
              if( isEmpty() ){
                  
                  throw new ArrayIndexOutOfBoundsException();
                  
              }
              
              T data=this.node.getData();
              
              this.node=this.node.getNext();
              
              len--;
              
              return data;
              
          }
          
      }
      
  	  static class Scanner{
          
          BufferedReader in;
          StringTokenizer st;
  
          public Scanner() {
          
              in=new BufferedReader( new InputStreamReader(System.in) );
              
          }
          
          String next() throws IOException{
              
              while(st==null || !st.hasMoreElements()){
                  
                  st=new StringTokenizer(in.readLine());
                  
              }
              
              return st.nextToken();
              
          }
          
          int nextInt() throws IOException{
              
              return Integer.parseInt(next());
              
          }
          
          long nextLong() throws IOException{
              
              return Long.parseLong(next());
              
          }
          
          String nextLine() throws IOException{
              
              return in.readLine();
              
          }
          
          char nextChar() throws IOException{
              
              return next().charAt(0);
              
          }
          
          double nextDouble() throws IOException{
              
              return Double.parseDouble(next());
              
          }
          
          float nextFloat() throws IOException{
              
              return Float.parseFloat(next());
              
          }
          
          boolean nextBoolean() throws IOException{
              
              return Boolean.parseBoolean(next());
              
          }
          
          void close() throws IOException{
              
              in.close();
              
          }
          
      }
  	
  }
  