import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int num = Integer.parseInt(scn.nextLine());
while (num-- != 0) {
int n = Integer.parseInt(scn.nextLine());
String arr[][] = new String[n][2];
for (int i = 0; i < n; i++) {
String s[] = scn.nextLine().split(" ");
arr[i][0] = s[0];
arr[i][1] = s[1];
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
for (int k = 0; k < n; k++) {
int a = Integer.parseInt(arr[i][1]), b = Integer.parseInt(arr[j][1]),
c = Integer.parseInt(arr[k][1]);
int x=arr[i][0].toCharArray()[0],y=arr[j][0].toCharArray()[0],z=arr[k][0].toCharArray()[0];
if (i != j && j != k && k != i&&x<y&&y<z&&x<z) {
if ((a >= 0 && b >= 0 && c >= 0) && a + b > c && b + c > a && a + c > b) {
System.out.println(arr[i][0] + " " + arr[j][0] + " " + arr[k][0]);
}
}
}
}
}
}
}
}