#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 511111;
long long m;
vector<vector<pair<long long, pair<long long, long long> > > > qry;
vector<vector<pair<long long, long long> > > g;
vector<long long> leafs, idx;
vector<long long> d, ans;
vector<pair<long long, long long> > border;
long long curt;
void dfs1(long long v, long long p, long long h) {
  if (v != 0 && g[v].size() == 1) {
    border[v] = {curt, curt};
    leafs.push_back(curt);
    d.push_back(h);
    curt++;
    return;
  }
  curt++;
  for (long long i = 0; i < g[v].size(); i++) {
    long long to = g[v][i].first;
    if (to == p) continue;
    dfs1(to, v, h + g[v][i].second);
    border[v] = {min(border[v].first, border[to].first),
                 max(border[v].second, border[to].second)};
  }
}
long long tree[4 * MAXN], add[4 * MAXN];
void build(long long tl, long long tr, long long v) {
  if (tl == tr) {
    tree[v] = d[tl];
    return;
  }
  long long mid = (tl + tr) >> 1;
  build(tl, mid, v << 1);
  build(mid + 1, tr, v << 1 | 1);
  tree[v] = min(tree[v << 1], tree[v << 1 | 1]);
}
void upd(long long tl, long long tr, long long v, long long l, long long r,
         long long x) {
  if (l > tr || r < tl) return;
  if (l <= tl && tr <= r) {
    add[v] += x;
    return;
  }
  long long mid = (tl + tr) >> 1;
  upd(tl, mid, v << 1, l, r, x);
  upd(mid + 1, tr, v << 1 | 1, l, r, x);
  tree[v] = min(tree[v << 1] + add[v << 1], tree[v << 1 | 1] + add[v << 1 | 1]);
}
long long get(long long tl, long long tr, long long v, long long l,
              long long r) {
  if (l > tr || r < tl) return LLONG_MAX;
  if (l <= tl && tr <= r) return (tree[v] + add[v]);
  long long mid = (tl + tr) >> 1;
  return (min(get(tl, mid, v << 1, l, r), get(mid + 1, tr, v << 1 | 1, l, r)) +
          add[v]);
}
void dfs2(long long v, long long p) {
  for (long long i = 0; i < qry[v].size(); i++) {
    long long num = qry[v][i].first, l = qry[v][i].second.first,
              r = qry[v][i].second.second;
    long long L = lower_bound(leafs.begin(), leafs.end(), l) - leafs.begin();
    long long R = lower_bound(leafs.begin(), leafs.end(), r) - leafs.begin();
    if (R == leafs.size() || leafs[R] > r) R--;
    ans[num] = get(0, m - 1, 1, L, R);
  }
  for (long long i = 0; i < g[v].size(); i++) {
    long long to = g[v][i].first;
    if (to == p) continue;
    upd(0, m - 1, 1, 0, m - 1, g[v][i].second);
    upd(0, m - 1, 1, idx[border[to].first], idx[border[to].second],
        -2 * g[v][i].second);
    dfs2(to, v);
    upd(0, m - 1, 1, 0, m - 1, -g[v][i].second);
    upd(0, m - 1, 1, idx[border[to].first], idx[border[to].second],
        2 * g[v][i].second);
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, q;
  cin >> n >> q;
  g.resize(n), qry.resize(n), border.resize(n, {INT_MAX, -1}), ans.resize(q);
  for (long long i = 1; i < n; i++) {
    long long p, w;
    cin >> p >> w;
    p--;
    g[p].push_back({i, w});
    g[i].push_back({p, w});
  }
  for (long long i = 0; i < n; i++) sort(g[i].begin(), g[i].end());
  for (long long i = 0; i < q; i++) {
    long long v, l, r;
    cin >> v >> l >> r;
    v--, l--, r--;
    qry[v].push_back({i, {l, r}});
  }
  dfs1(0, -1, 0);
  m = leafs.size();
  idx.resize(n);
  for (long long i = 0; i < m; i++) idx[leafs[i]] = i;
  build(0, m - 1, 1);
  dfs2(0, -1);
  for (long long i = 0; i < q; i++) cout << ans[i] << '\n';
  return 0;
}
