#include<bits/stdc++.h>
using namespace std;



int main()
{
	freopen("query.in","r",stdin);
	freopen("query.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<n;i++)scanf("%*d %*d");
	scanf("%d",&q);
	while(q--)
	{
		int l,r,k;
		scanf("%d %d %d",&l,&r,&k);
		printf("%d\n",max(l,r)-k+1);
	}
	return 0;
} 
