#include <iostream>
#include <cstdio>
#include <map>
using namespace std;

int main()
{
	freopen("query.in","r",stdin);
	freopen("query.out","w",stdout);
	int n,q;
	cin >> n;
	for(int i=1;i<n;i++)
	{
		int u,v;
		cin >> u >> v;
	}
	cin >> q;
	while(q--)
	{
		int l,r,k;
		cin >> l >> r >> k;
		cout << r-k+1 << endl;
	}
	return 0;
}
