#include <bits/stdc++.h>
using namespace std;
const int MAXN = 511111;
int m;
vector<vector<pair<int, pair<int, int> > > > qry;
vector<vector<pair<int, int> > > g;
vector<int> leafs, idx;
vector<long long> d, ans;
vector<pair<int, int> > border;
int curt;
void dfs1(int v, int 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 (int i = 0; i < g[v].size(); i++) {
    int 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(int tl, int tr, int v) {
  if (tl == tr) {
    tree[v] = d[tl];
    return;
  }
  int 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(int tl, int tr, int v, int l, int r, int x) {
  if (l > tr || r < tl) return;
  if (l <= tl && tr <= r) {
    add[v] += x;
    return;
  }
  int mid = (tl + tr) >> 1;
  upd(tl, mid, v << 1, l, r, x);
  upd(mid + 1, r, 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(int tl, int tr, int v, int l, int r) {
  if (l > tr || r < tl) return LLONG_MAX;
  if (l <= tl && tr <= r) return (tree[v] + add[v]);
  int 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(int v, int p) {
  for (int i = 0; i < qry[v].size(); i++) {
    int num = qry[v][i].first, l = qry[v][i].second.first,
        r = qry[v][i].second.second;
    int L = lower_bound(leafs.begin(), leafs.end(), l) - leafs.begin();
    int 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 (int i = 0; i < g[v].size(); i++) {
    int 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);
  int n, q;
  cin >> n >> q;
  g.resize(n), qry.resize(n), border.resize(n, {INT_MAX, -1}), ans.resize(q);
  for (int i = 1; i < n; i++) {
    int p, w;
    cin >> p >> w;
    p--;
    g[p].push_back({i, w});
    g[i].push_back({p, w});
  }
  for (int i = 0; i < q; i++) {
    int 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 (int i = 0; i < m; i++) idx[leafs[i]] = i;
  build(0, m - 1, 1);
  dfs2(0, -1);
  for (int i = 0; i < q; i++) cout << ans[i] << '\n';
  return 0;
}
