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.*;
  import java.util.*;
  
  /**
   * Provide prove of correctness before implementation. Implementation can cost a lot of time.
   * Anti test that prove that it's wrong.
   * <p>
   * Do not confuse i j k g indexes, upTo and length. Do extra methods!!! Write more informative names to simulation
   * <p>
   * Will program ever exceed limit?
   * Try all approaches with prove of correctness if task is not obvious.
   * If you are given formula/rule: Try to play with it.
   * Analytic solution/Hardcoded solution/Constructive/Greedy/DP/Math/Brute force/Symmetric data
   * Number theory
   * Game theory (optimal play) that consider local and global strategy.
   */
  public class B {
  
      private void solveOne() {
          int n = nextInt();
          int[] l = new int[n];
          int[] r = new int[n];
  
          for (int i = 0; i < n; i++) {
              l[i] = nextInt();
              r[i] = nextInt();
          }
  
          Set<Integer> printed = new HashSet<>();
  
          Deque<Pair> deque = new ArrayDeque<>();
          deque.add(new Pair(1, n));
  
          outer:
          while (!deque.isEmpty()) {
  
              Pair range = deque.removeFirst();
              if (range.l == range.r) {
                  System.out.print(range.l);
                  System.out.print(' ');
                  System.out.print(range.r);
                  System.out.print(' ');
                  System.out.print(range.l);
                  System.out.print('\n');
                  continue;
              }
  
              //d[]
              for (int i = 0; i < n; i++) {
                  if (range.l + 1 == l[i] && range.r == r[i]) {
                      System.out.print(range.l);
                      System.out.print(' ');
                      System.out.print(range.r);
                      System.out.print(' ');
                      System.out.print(range.l);
                      System.out.print('\n');
                      deque.add(new Pair(l[i], r[i]));
                      continue outer;
                  }
              }
  
              //[]d
              for (int i = 0; i < n; i++) {
                  if (range.l == l[i] && range.r - 1 == r[i]) {
                      System.out.print(range.l);
                      System.out.print(' ');
                      System.out.print(range.r);
                      System.out.print(' ');
                      System.out.print(range.r);
                      System.out.print('\n');
                      deque.add(new Pair(l[i], r[i]));
                      continue outer;
                  }
              }
  
              //[]d[]
              int lenSum = range.r - range.l;//range - 1 []d[]
              Map<String, Pair> map = new HashMap<>();
              for (int i = 0; i < n; i++) {
  
                  int curLen = r[i] - l[i] + 1;
                  int needLen = lenSum - curLen;
  
                  //if this is right, look for the left
                  int posLeftStart = l[i] - needLen - 1;
                  if (map.containsKey(key(posLeftStart, needLen)) && range.r == r[i]) {
                      System.out.print(range.l);
                      System.out.print(' ');
                      System.out.print(range.r);
                      System.out.print(' ');
                      System.out.print(l[i] - 1);
                      System.out.print('\n');
  
                      deque.add(new Pair(posLeftStart, l[i] - 2));
                      deque.add(new Pair(l[i], r[i]));
                      continue outer;
                  }
  
  
                  //if this is left, look for the right
                  int posRightStart = r[i] + 2;
                  if (map.containsKey(key(posRightStart, needLen)) && range.l == l[i]) {
                      System.out.print(range.l);
                      System.out.print(' ');
                      System.out.print(range.r);
                      System.out.print(' ');
                      System.out.print(r[i] + 1);
                      System.out.print('\n');
  
                      deque.add(new Pair(l[i], r[i]));
                      deque.add(new Pair(posRightStart, posRightStart + needLen - 1));
  
                      continue outer;
                  }
  
                  map.put(key(l[i], curLen), new Pair(l[i], r[i]));
              }
  
          }
          System.out.println();
  
      }
  
      String key(int start, int len) {
          return start + "?" + len;
      }
  
      class Pair {
          int l;
          int r;
  
          public Pair(int l, int second) {
              this.l = l;
              this.r = second;
          }
      }
  
      private void solve() {
          int t = System.in.readInt();
          for (int tt = 0; tt < t; tt++) {
              solveOne();
          }
      }
  
      class AssertionRuntimeException extends RuntimeException {
  
          AssertionRuntimeException(Object expected,
                                    Object actual, Object... input) {
              super("expected = " + expected + ",\n actual = " + actual + ",\n " + Arrays.deepToString(input));
          }
      }
  
      private int nextInt() {
          return System.in.readInt();
      }
  
      private long nextLong() {
          return System.in.readLong();
      }
  
      private String nextString() {
          return System.in.readString();
      }
  
      private int[] nextIntArr(int n) {
          return System.in.readIntArray(n);
      }
  
      private long[] nextLongArr(int n) {
          return System.in.readLongArray(n);
      }
  
  
      public static void main(String[] args) {
          new B().run();
      }
  
      static class System {
          private static FastInputStream in;
          private static FastPrintStream out;
      }
  
      private void run() {
          System.in = new FastInputStream(java.lang.System.in);
          System.out = new FastPrintStream(java.lang.System.out);
          solve();
          System.out.flush();
      }
  
      private static class FastPrintStream {
          private static final int BUF_SIZE = 8192;
          private final byte[] buf = new byte[BUF_SIZE];
          private final OutputStream out;
          private int ptr = 0;
  
          private FastPrintStream() {
              this(java.lang.System.out);
          }
  
          public FastPrintStream(OutputStream os) {
              this.out = os;
          }
  
          public FastPrintStream(String path) {
              try {
                  this.out = new FileOutputStream(path);
              } catch (FileNotFoundException e) {
                  throw new RuntimeException("FastWriter");
              }
          }
  
          public FastPrintStream print(byte b) {
              buf[ptr++] = b;
              if (ptr == BUF_SIZE) innerflush();
              return this;
          }
  
          public FastPrintStream print(char c) {
              return print((byte) c);
          }
  
          public FastPrintStream print(char[] s) {
              for (char c : s) {
                  buf[ptr++] = (byte) c;
                  if (ptr == BUF_SIZE) innerflush();
              }
              return this;
          }
  
          public FastPrintStream print(String s) {
              s.chars().forEach(c -> {
                  buf[ptr++] = (byte) c;
                  if (ptr == BUF_SIZE) innerflush();
              });
              return this;
          }
  
          //can be optimized
          public FastPrintStream print0(char[] s) {
              if (ptr + s.length < BUF_SIZE) {
                  for (char c : s) {
                      buf[ptr++] = (byte) c;
                  }
              } else {
                  for (char c : s) {
                      buf[ptr++] = (byte) c;
                      if (ptr == BUF_SIZE) innerflush();
                  }
              }
              return this;
          }
  
          //can be optimized
          public FastPrintStream print0(String s) {
              if (ptr + s.length() < BUF_SIZE) {
                  for (int i = 0; i < s.length(); i++) {
                      buf[ptr++] = (byte) s.charAt(i);
                  }
              } else {
                  for (int i = 0; i < s.length(); i++) {
                      buf[ptr++] = (byte) s.charAt(i);
                      if (ptr == BUF_SIZE) innerflush();
                  }
              }
              return this;
          }
  
          private static int countDigits(int l) {
              if (l >= 1000000000) return 10;
              if (l >= 100000000) return 9;
              if (l >= 10000000) return 8;
              if (l >= 1000000) return 7;
              if (l >= 100000) return 6;
              if (l >= 10000) return 5;
              if (l >= 1000) return 4;
              if (l >= 100) return 3;
              if (l >= 10) return 2;
              return 1;
          }
  
          public FastPrintStream print(int x) {
              if (x == Integer.MIN_VALUE) {
                  return print((long) x);
              }
              if (ptr + 12 >= BUF_SIZE) innerflush();
              if (x < 0) {
                  print((byte) '-');
                  x = -x;
              }
              int d = countDigits(x);
              for (int i = ptr + d - 1; i >= ptr; i--) {
                  buf[i] = (byte) ('0' + x % 10);
                  x /= 10;
              }
              ptr += d;
              return this;
          }
  
          private static int countDigits(long l) {
              if (l >= 1000000000000000000L) return 19;
              if (l >= 100000000000000000L) return 18;
              if (l >= 10000000000000000L) return 17;
              if (l >= 1000000000000000L) return 16;
              if (l >= 100000000000000L) return 15;
              if (l >= 10000000000000L) return 14;
              if (l >= 1000000000000L) return 13;
              if (l >= 100000000000L) return 12;
              if (l >= 10000000000L) return 11;
              if (l >= 1000000000L) return 10;
              if (l >= 100000000L) return 9;
              if (l >= 10000000L) return 8;
              if (l >= 1000000L) return 7;
              if (l >= 100000L) return 6;
              if (l >= 10000L) return 5;
              if (l >= 1000L) return 4;
              if (l >= 100L) return 3;
              if (l >= 10L) return 2;
              return 1;
          }
  
          public FastPrintStream print(long x) {
              if (x == Long.MIN_VALUE) {
                  return print("" + x);
              }
              if (ptr + 21 >= BUF_SIZE) innerflush();
              if (x < 0) {
                  print((byte) '-');
                  x = -x;
              }
              int d = countDigits(x);
              for (int i = ptr + d - 1; i >= ptr; i--) {
                  buf[i] = (byte) ('0' + x % 10);
                  x /= 10;
              }
              ptr += d;
              return this;
          }
  
          public FastPrintStream print(double x, int precision) {
              if (x < 0) {
                  print('-');
                  x = -x;
              }
              x += Math.pow(10, -precision) / 2;
              //		if(x < 0){ x = 0; }
              print((long) x).print(".");
              x -= (long) x;
              for (int i = 0; i < precision; i++) {
                  x *= 10;
                  print((char) ('0' + (int) x));
                  x -= (int) x;
              }
              return this;
          }
  
          public FastPrintStream println(int[] a, int from, int upTo, char separator) {
              for (int i = from; i < upTo; i++) {
                  print(a[i]);
                  print(separator);
              }
              print('\n');
              return this;
          }
  
          public FastPrintStream println(int[] a) {
              return println(a, 0, a.length, ' ');
          }
  
          public FastPrintStream println(char c) {
              return print(c).println();
          }
  
          public FastPrintStream println(int x) {
              return print(x).println();
          }
  
          public FastPrintStream println(long x) {
              return print(x).println();
          }
  
          public FastPrintStream println(String x) {
              return print(x).println();
          }
  
          public FastPrintStream println(double x, int precision) {
              return print(x, precision).println();
          }
  
          public FastPrintStream println() {
              return print((byte) '\n');
          }
  
          private void innerflush() {
              try {
                  out.write(buf, 0, ptr);
                  ptr = 0;
              } catch (IOException e) {
                  throw new RuntimeException("innerflush");
              }
          }
  
          public void flush() {
              innerflush();
              try {
                  out.flush();
              } catch (IOException e) {
                  throw new RuntimeException("flush");
              }
          }
      }
  
      private static class FastInputStream {
          private boolean finished = false;
  
          private InputStream stream;
          private byte[] buf = new byte[1024];
          private int curChar;
          private int numChars;
          private SpaceCharFilter filter;
  
          public FastInputStream(InputStream stream) {
              this.stream = stream;
          }
  
          public double[] readDoubleArray(int size) {
              double[] array = new double[size];
              for (int i = 0; i < size; i++) {
                  array[i] = readDouble();
              }
              return array;
          }
  
          public String[] readStringArray(int size) {
              String[] array = new String[size];
              for (int i = 0; i < size; i++) {
                  array[i] = readString();
              }
              return array;
          }
  
          public char[] readCharArray(int size) {
              char[] array = new char[size];
              for (int i = 0; i < size; i++) {
                  array[i] = readCharacter();
              }
              return array;
          }
  
          public void readIntArrays(int[]... arrays) {
              for (int i = 0; i < arrays[0].length; i++) {
                  for (int j = 0; j < arrays.length; j++) {
                      arrays[j][i] = readInt();
                  }
              }
          }
  
          public void readLongArrays(long[]... arrays) {
              for (int i = 0; i < arrays[0].length; i++) {
                  for (int j = 0; j < arrays.length; j++) {
                      arrays[j][i] = readLong();
                  }
              }
          }
  
          public void readDoubleArrays(double[]... arrays) {
              for (int i = 0; i < arrays[0].length; i++) {
                  for (int j = 0; j < arrays.length; j++) {
                      arrays[j][i] = readDouble();
                  }
              }
          }
  
          public char[][] readTable(int rowCount, int columnCount) {
              char[][] table = new char[rowCount][];
              for (int i = 0; i < rowCount; i++) {
                  table[i] = this.readCharArray(columnCount);
              }
              return table;
          }
  
          public int[][] readIntTable(int rowCount, int columnCount) {
              int[][] table = new int[rowCount][];
              for (int i = 0; i < rowCount; i++) {
                  table[i] = readIntArray(columnCount);
              }
              return table;
          }
  
          public double[][] readDoubleTable(int rowCount, int columnCount) {
              double[][] table = new double[rowCount][];
              for (int i = 0; i < rowCount; i++) {
                  table[i] = this.readDoubleArray(columnCount);
              }
              return table;
          }
  
          public long[][] readLongTable(int rowCount, int columnCount) {
              long[][] table = new long[rowCount][];
              for (int i = 0; i < rowCount; i++) {
                  table[i] = readLongArray(columnCount);
              }
              return table;
          }
  
          public String[][] readStringTable(int rowCount, int columnCount) {
              String[][] table = new String[rowCount][];
              for (int i = 0; i < rowCount; i++) {
                  table[i] = this.readStringArray(columnCount);
              }
              return table;
          }
  
          public String readText() {
              StringBuilder result = new StringBuilder();
              while (true) {
                  int character = read();
                  if (character == '\r') {
                      continue;
                  }
                  if (character == -1) {
                      break;
                  }
                  result.append((char) character);
              }
              return result.toString();
          }
  
          public void readStringArrays(String[]... arrays) {
              for (int i = 0; i < arrays[0].length; i++) {
                  for (int j = 0; j < arrays.length; j++) {
                      arrays[j][i] = readString();
                  }
              }
          }
  
          public long[] readLongArray(int size) {
              long[] array = new long[size];
              for (int i = 0; i < size; i++) {
                  array[i] = readLong();
              }
              return array;
          }
  
          public int[] readIntArray(int size) {
              int[] array = new int[size];
              for (int i = 0; i < size; i++) {
                  array[i] = readInt();
              }
              return array;
          }
  
          public int read() {
              if (numChars == -1) {
                  throw new InputMismatchException();
              }
              if (curChar >= numChars) {
                  curChar = 0;
                  try {
                      numChars = stream.read(buf);
                  } catch (IOException e) {
                      throw new InputMismatchException();
                  }
                  if (numChars <= 0) {
                      return -1;
                  }
              }
              return buf[curChar++];
          }
  
          public int peek() {
              if (numChars == -1) {
                  return -1;
              }
              if (curChar >= numChars) {
                  curChar = 0;
                  try {
                      numChars = stream.read(buf);
                  } catch (IOException e) {
                      return -1;
                  }
                  if (numChars <= 0) {
                      return -1;
                  }
              }
              return buf[curChar];
          }
  
          public int peekNonWhitespace() {
              while (isWhitespace(peek())) {
                  read();
              }
              return peek();
          }
  
          public int readInt() {
              int c = read();
              while (isSpaceChar(c)) {
                  c = read();
              }
              int sgn = 1;
              if (c == '-') {
                  sgn = -1;
                  c = read();
              }
              int res = 0;
              do {
                  if (c < '0' || c > '9') {
                      throw new InputMismatchException();
                  }
                  res *= 10;
                  res += c - '0';
                  c = read();
              } while (!isSpaceChar(c));
              return res * sgn;
          }
  
          public long readLong() {
              int c = read();
              while (isSpaceChar(c)) {
                  c = read();
              }
              int sgn = 1;
              if (c == '-') {
                  sgn = -1;
                  c = read();
              }
              long res = 0;
              do {
                  if (c < '0' || c > '9') {
                      throw new InputMismatchException();
                  }
                  res *= 10;
                  res += c - '0';
                  c = read();
              } while (!isSpaceChar(c));
              return res * sgn;
          }
  
          public String readString() {
              int c = read();
              while (isSpaceChar(c)) {
                  c = read();
              }
              StringBuilder res = new StringBuilder();
              do {
                  if (Character.isValidCodePoint(c)) {
                      res.appendCodePoint(c);
                  }
                  c = read();
              } while (!isSpaceChar(c));
              return res.toString();
          }
  
          public boolean isSpaceChar(int c) {
              if (filter != null) {
                  return filter.isSpaceChar(c);
              }
              return isWhitespace(c);
          }
  
          public static boolean isWhitespace(int c) {
              return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
          }
  
          private String readLine0() {
              StringBuilder buf = new StringBuilder();
              int c = read();
              while (c != '\n' && c != -1) {
                  if (c != '\r') {
                      buf.appendCodePoint(c);
                  }
                  c = read();
              }
              return buf.toString();
          }
  
          public String readLine() {
              String s = readLine0();
              while (s.trim().length() == 0) {
                  s = readLine0();
              }
              return s;
          }
  
          public String readLine(boolean ignoreEmptyLines) {
              if (ignoreEmptyLines) {
                  return readLine();
              } else {
                  return readLine0();
              }
          }
  
          public char readCharacter() {
              int c = read();
              while (isSpaceChar(c)) {
                  c = read();
              }
              return (char) c;
          }
  
          public double readDouble() {
              int c = read();
              while (isSpaceChar(c)) {
                  c = read();
              }
              int sgn = 1;
              if (c == '-') {
                  sgn = -1;
                  c = read();
              }
              double res = 0;
              while (!isSpaceChar(c) && c != '.') {
                  if (c == 'e' || c == 'E') {
                      return res * Math.pow(10, readInt());
                  }
                  if (c < '0' || c > '9') {
                      throw new InputMismatchException();
                  }
                  res *= 10;
                  res += c - '0';
                  c = read();
              }
              if (c == '.') {
                  c = read();
                  double m = 1;
                  while (!isSpaceChar(c)) {
                      if (c == 'e' || c == 'E') {
                          return res * Math.pow(10, readInt());
                      }
                      if (c < '0' || c > '9') {
                          throw new InputMismatchException();
                      }
                      m /= 10;
                      res += (c - '0') * m;
                      c = read();
                  }
              }
              return res * sgn;
          }
  
          public boolean isExhausted() {
              int value;
              while (isSpaceChar(value = peek()) && value != -1) {
                  read();
              }
              return value == -1;
          }
  
          public String next() {
              return readString();
          }
  
          public SpaceCharFilter getFilter() {
              return filter;
          }
  
          public void setFilter(SpaceCharFilter filter) {
              this.filter = filter;
          }
  
          public interface SpaceCharFilter {
              public boolean isSpaceChar(int ch);
          }
      }
  
  }