#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define pb push_back
#define F first
#define S second
#define lll long long
#define lld long double

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree <T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

const int N = 5e5 + 229;
const int M = 1e9 + 83;
const int M2 = 1e9 + 7;
const int MM = 1e9 + 7;
const int mod = 998244353;
const int rx[8] = {1, 1, -1, -1, -2, -2, 2, 2};
const int ry[8] = {-2, 2, -2, 2, 1, -1, 1, -1};
const lld eps = 1e-7;
const double pi = acos(-1.0);

vector < lll > d, lazy;

vector < pair < int, int > > g[N], all;

vector < pair < pair < int, int >, int > > q[N];

pair < lll, lll > calc[N];

lll ans[N];

int st;

void dfs(int v, lll now = 0) {
    calc[v] = {1e18, -1e18};
    if (g[v].empty()) {
        all.pb({v, now});
        return;
    }
    for (auto to : g[v]) {
        dfs(to.F, now + to.S);
    }
}

void recalc(int v) {
    for (auto to : g[v]) {
        recalc(to.F);
        calc[v].F = min(calc[v].F, calc[to.F].F);
        calc[v].S = max(calc[v].S, calc[to.F].S);
    }
}

void push(int v) {
    d[v * 2] += lazy[v];
    d[v * 2 + 1] += lazy[v];
    lazy[v * 2] += lazy[v];
    lazy[v * 2 + 1] += lazy[v];
    lazy[v] = 0;
}

lll solve(int v, int l, int r, int cl, int cr) {
    if (cl >= r || cr <= l) {
        return 1e18;
    }
    if (cl >= l && cr <= r) {
        return d[v];
    }
    push(v);
    int mid = (cl + cr) / 2;
    return min(solve(v * 2, l, r, cl, mid), solve(v * 2 + 1, l, r, mid, cr));
}

void upd(int v, int l, int r, int cl, int cr, lll x) {
    if (cl >= r || cr <= l) {
        return;
    }
    if (cl >= l && cr <= r) {
        d[v] += x;
        lazy[v] += x;
        return;
    }
    push(v);
    int mid = (cl + cr) / 2;
    upd(v * 2, l, r, cl, mid, x);
    upd(v * 2 + 1, l, r, mid, cr, x);
    d[v] = min(d[v * 2], d[v * 2 + 1]);
}

void solve(int v) {
    for (auto i : q[v]) {
        ans[i.S] = solve(1, i.F.F, i.F.S + 1, 0, 1 << st);
    }
    for (auto to : g[v]) {
        if (calc[to.F].F) {
            upd(1, 0, calc[to.F].F, 0, 1 << st, to.S);
        }
        if (calc[to.F].S + 1 < int(all.size())) {
            upd(1, calc[to.F].S + 1, int(all.size()), 0, 1 << st, to.S);
        }
        upd(1, calc[to.F].F, calc[to.F].S + 1, 0, 1 << st, -(to.S));
        solve(to.F);
        if (calc[to.F].F) {
            upd(1, 0, calc[to.F].F, 0, 1 << st, -(to.S));
        }
        if (calc[to.F].S + 1 < int(all.size())) {
            upd(1, calc[to.F].S + 1, int(all.size()), 0, 1 << st, -(to.S));
        }
        upd(1, calc[to.F].F, calc[to.F].S + 1, 0, 1 << st, to.S);
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    srand(time(0));
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
//    freopen("dictionary.in", "r", stdin);
//    freopen("dictionary.out", "w", stdout);
#endif
    int n, m, p, w;
    cin >> n >> m;
    for (int i = 1; i < n; ++i) {
        cin >> p >> w;
        --p;
        g[p].pb({i, w});
    }
    dfs(0);
    while (1 << st < int(all.size())) {
        ++st;
    }
    d.resize(1 << (st + 1), 1e18);
    lazy.resize(1 << (st + 1));
    for (int i = 0; i < int(all.size()); ++i) {
        d[(1 << st) + i] = all[i].S;
        calc[all[i].F] = {i, i};
    }
    recalc(0);
    for (int i = (1 << st) - 1; i; --i) {
        d[i] = min(d[i * 2], d[i * 2 + 1]);
    }
    sort(all.begin(), all.end());
    int l, r, v;
    pair < int, int > kek;
    for (int i = 0; i < m; ++i) {
        cin >> v >> l >> r;
        --v;
        --l;
        --r;
        kek = {l, -1e9};
        l = int(lower_bound(all.begin(), all.end(), kek) - all.begin());
        kek = {r + 1, -1e9};
        if (all.back().F <= r) {
            r = int(all.size()) - 1;
        } else {
            r = int(lower_bound(all.begin(), all.end(), kek) - all.begin());
            --r;
        }
        q[v].pb({{l, r}, i});
    }
    solve(0);
    for (int i = 0; i < m; ++i) {
        cout << ans[i] << '\n';
    }
    return 0;
}
