#include<cstdio>
#include<vector>
using namespace std;
vector<int>graph[500010];
int n,q,degree[500010],dep[500010],fa[500010],top[500010],siz[500010],son[500010],pre_lca[5010][5010];
void dfs1(int now,int father)
{
	dep[now]=dep[father]+1;
	fa[now]=father;
	siz[now]=1;
	for(auto to:graph[now])
	{
		if(to==father) continue;
		dfs1(to,now);
		siz[now]+=siz[to];
		if(siz[to]>siz[son[now]]) son[now]=to;
	}
}
void dfs2(int now,int root)
{
	top[now]=root;
	if(son[now]) dfs2(son[now],root);
	for(auto to:graph[now])
	{
		if(to==fa[now]||to==son[now]) continue;
		dfs2(to,to);
	}
}
int lca(int x,int y)
{
	while(top[x]!=top[y])
	{
		if(dep[x]<dep[y]) swap(x,y);
		x=fa[top[x]];
	}
	if(dep[x]>dep[y]) swap(x,y);
	return x;
}
int main()
{
	freopen("query.in","r",stdin);
	freopen("query.out","w",stdout);
	scanf("%d",&n);
	bool checkChain=1;
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		graph[u].push_back(v);
		graph[v].push_back(u);
		degree[u]++;degree[v]++;
		if(degree[u]>2||degree[v]>2||degree[1]>1) checkChain=0;
	}
	dfs1(1,0);
	dfs2(1,1);
	if(checkChain)
	{
	}
	else
	{
		for(int i=1;i<=n;i++)
			for(int j=i+1;j<=n;j++)
				pre_lca[i][j]=lca(i,j);
		scanf("%d",&q);
		while(q--)
		{
			int l,r,k;
			scanf("%d%d%d",&l,&r,&k);
			int nowl=l,nowr=l+k-1;
			
		}
	}
}