import java.util.*;
public class TreeTestCases {
static final int MAXNODE = 10;
static final int MAXT = 10;
static final int MAXWEIGHT = 100;
static int find(int[] parent, int x) {
if (parent[x] == x) {
return x;
}
parent[x] = find(parent, parent[x]);
return parent[x];
}
static void merge(int[] parent, int[] size, int x, int y) {
int r1 = find(parent, x);
int r2 = find(parent, y);
if (size[r1] < size[r2]) {
parent[r1] = r2;
size[r2] += size[r1];
} else {
parent[r2] = r1;
size[r1] += size[r2];
}
}
static void generate() {
Random rand = new Random();
int t = rand.nextInt(MAXT) + 1;
System.out.println(t);
for (int i = 0; i < t; i++) {
int n = rand.nextInt(MAXNODE - 1) + 2;
System.out.println(n);
int[] parent = new int[n + 1];
int[] size = new int[n + 1];
for (int j = 1; j <= n; j++) {
parent[j] = j;
size[j] = 1;
}
List<int[]> edges = new ArrayList<>();
List<Integer> weights = new ArrayList<>();
for (int j = 0; j < n - 1; j++) {
int x = rand.nextInt(n) + 1;
int y = rand.nextInt(n) + 1;
while (find(parent, x) == find(parent, y)) {
x = rand.nextInt(n) + 1;
y = rand.nextInt(n) + 1;
}
merge(parent, size, x, y);
edges.add(new int[] {x, y});
int w = rand.nextInt(MAXWEIGHT) + 1;
weights.add(w);
}
for (int j = 0; j < edges.size(); j++) {
int[] edge = edges.get(j);
System.out.println(edge[0] + " " + edge[1] + " " + weights.get(j));
}
}
}
public static void main(String[] args) {
Random rand = new Random();
rand.setSeed(System.currentTimeMillis());
generate();
}
}