#include <bits/stdc++.h>
#define int long long
#define N 500005
using namespace std;
int n, q;

inline int read() {
	int x = 0, m = 1;
	char ch = 0;
	while (!isdigit(ch)) {
		if (ch == '-') m = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = (x << 1) + (x << 3) + ch - 48;
		ch = getchar();
	}
	return x * m;
}

signed main() {
	freopen("query.in", "r", stdin);
	freopen("query.out", "w", stdout);
	n = read();
	for (int i = 1; i < n; i++) {
		int u = read(), v = read();
	}
	q = read();
	for (int i = 1; i <= n; i++) {
		int l = read(), r = read(), k = read();
		printf("1\n");
	}
	return 0;
}

