#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second

using namespace std;
using ll = long long;
using pii = pair<int, int>;

void SetIO(string s = "")
{
    if (s != "")
    {
        freopen((s + ".in").c_str(), "r", stdin);
        freopen((s + ".out").c_str(), "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);
}

namespace IO
{
    const int SIZE = 1 << 21;
    char buf[SIZE], *p1 = buf, *p2 = buf;
    char Gc(){return (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, SIZE, stdin), p1 == p2)) ? EOF : *p1++;}
    int Read()
    {
        int s = 0;
        char ch = Gc();
        while(ch < '0' || ch > '9')
            ch = Gc();
        while(ch >= '0' && ch <= '9')
            s = (s << 1) + (s << 3) + (ch ^ 48), ch = Gc();
        return s;
    }
    char pbuf[SIZE], *pp = pbuf;
    int sta[20];
    void Flush(){fwrite(pbuf, 1, pp - pbuf, stdout); pp = pbuf;}
    void Pc(char ch){if (pp == pbuf + SIZE) Flush(); *pp++ = ch;}
    void Write(int x)
    {
        int top = 0;
        do
        {
            sta[++top] = x % 10;
            x /= 10;
        }while(x);
        while(top)
            Pc(sta[top--] + '0');
    }
    void Write(int x, char ch){Write(x), Pc(ch);}
}
using namespace IO;

const int N = 5e5 + 5;

int n, q, rt[N], deep[N];
vector<int> adj[N], edge[N];

class SegmentTree{
    public:
        int cur, ls[N << 5], rs[N << 5];
        struct Node{
            int left, right, maxn;
            bool bj;
            Node operator + (const Node& rhs) const
            {
                Node res;
                res.left = left;
                res.right = rhs.right;
                if (bj)
                    res.left += rhs.left;
                if (rhs.bj)
                    res.right += right;
                res.bj = bj & rhs.bj;
                res.maxn = max(max(maxn, rhs.maxn), right + rhs.left);
                res.maxn = max(res.maxn, max(res.left, res.right));
                return res;
            }
        }tree[N << 5];
    public:
        int Modify(int pre, int pos, int l = 1, int r = n)
        {
            int now = ++cur;
            ls[now] = ls[pre], rs[now] = rs[pre];
            if (l == r)
            {
                tree[now] = Node{1, 1, 1, true};
                return now;
            }
            int mid = (l + r) >> 1;
            if (pos <= mid)
                ls[now] = Modify(ls[pre], pos, l, mid);
            else
                rs[now] = Modify(rs[pre], pos, mid + 1, r);
            tree[now] = tree[ls[now]] + tree[rs[now]];
            return now;
        }
        Node Query(int now, int s, int t, int l = 1, int r = n)
        {
            if (s <= l && r <= t)
                return tree[now];
            int mid = (l + r) >> 1;
            if (t <= mid)
                return Query(ls[now], s, t, l, mid);
            if (s > mid)
                return Query(rs[now], s, t, mid + 1, r);
            return Query(ls[now], s, t, l, mid) + Query(rs[now], s, t, mid + 1, r);
        }
}sgt;

void Dfs(int, int);

signed main()
{
    SetIO("query");
    n = Read();
    for (int i = 1, u, v; i < n; i++)
    {
        u = Read(), v = Read();
        edge[u].eb(v);
        edge[v].eb(u);
    }
    deep[1] = 1;
    Dfs(1, 0);
    for (int i = n; i >= 1; i--)
    {
        rt[i] = rt[i + 1];
        for (int j : adj[i])
            rt[i] = sgt.Modify(rt[i], j);
    }
    q = Read();
    while(q--)
    {
        int l, r, k, ans = -1;
        l = Read(), r = Read(), k = Read();
        int lb = 1, rb = n;
        while(lb <= rb)
        {
            int mid = (lb + rb) >> 1;
            if (sgt.Query(rt[mid], l, r).maxn >= k)
                ans = mid, lb = mid + 1;
            else
                rb = mid - 1;
        }
        Write(ans, '\n');
    }
    Flush();
    return 0;
}

void Dfs(int u, int fa)
{
    adj[deep[u]].eb(u);
    for (int v : edge[u])if (v != fa)
    {
        deep[v] = deep[u] + 1;
        Dfs(v, u);
    }
}