T = int(input())
for _ in range(T):
n = int(input())
ranges = []
for i in range(n):
x, y = map(int, input().split())
ranges.append([x,y])
ranges.sort()
marker = []
i = 0
while i < n:
if len(marker) == 0:
marker.append(ranges[i])
elif ranges[i][0] == marker[-1][0]:
marker = [ranges[i]] + marker
else:
for j in range(len(marker)-1):
if marker[j][1] - marker[j+1][1] == 1:
print(str(marker[j][0]) + ' ' + str(marker[j][1]) + ' ' + str(marker[j][1]))
else:
print(str(marker[j][0]) + ' ' + str(marker[j][1]) + ' ' + str(marker[j+1][1]+1))
if marker[-1][1] == marker[-1][0]:
print(str(marker[-1][0]) + ' ' + str(marker[-1][1]) + ' ' + str(marker[-1][1]))
else:
if ranges[i][0] - marker[0][0] == 1:
print(str(marker[-1][0]) + ' ' + str(marker[-1][1]) + ' ' + str(marker[-1][0]))
else:
print(str(marker[-1][0]) + ' ' + str(marker[-1][1]) + ' ' + str(ranges[i][0]-1))
marker = [ranges[i]]
i += 1
for j in range(len(marker) - 1):
if marker[j][1] - marker[j + 1][1] == 1:
print(str(marker[j][0]) + ' ' + str(marker[j][1]) + ' ' + str(marker[j][1]))
else:
print(str(marker[j][0]) + ' ' + str(marker[j][1]) + ' ' + str(marker[j + 1][1] + 1))
print(str(marker[-1][0]) + ' ' + str(marker[-1][1]) + ' ' + str(marker[-1][1]))
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int l[n],r[n];
for(int i=0;i<n;i++)
cin>>l[i]>>r[i];
for(int i=0;i<n;i++)
{
int ans=l[i];
for(int j=0;j<n;j++)
if(l[j]==l[i]&&r[j]<r[i])
ans=max(ans,r[j]+1);
cout<<l[i]<<" "<<r[i]<<" "<<ans<<"\n";
}
}
}
53A - Autocomplete | 1729G - Cut Substrings |
805B - 3-palindrome | 805C - Find Amir |
676C - Vasya and String | 1042B - Vitamins |
1729F - Kirei and the Linear Function | 25D - Roads not only in Berland |
1694A - Creep | 659F - Polycarp and Hay |
1040A - Palindrome Dance | 372A - Counting Kangaroos is Fun |
1396B - Stoned Game | 16A - Flag |
1056A - Determine Line | 670B - Game of Robots |
1418C - Mortal Kombat Tower | 1382B - Sequential Nim |
1272C - Yet Another Broken Keyboard | 808A - Lucky Year |
1245A - Good ol' Numbers Coloring | 58B - Coins |
1041C - Coffee Break | 507A - Amr and Music |
1041D - Glider | 1486A - Shifting Stacks |
1389B - Array Walk | 71B - Progress Bar |
701A - Cards | 545A - Toy Cars |