#include <bits/stdc++.h>
using namespace std;
class intervalac {
  vector<int> l, r;
  vector<long long> v, lazy;
  void unlazy(int vr) {
    v[vr * 2 + 1] += lazy[vr];
    v[vr * 2 + 2] += lazy[vr];
    lazy[vr * 2 + 1] += lazy[vr];
    lazy[vr * 2 + 2] += lazy[vr];
    lazy[vr] = 0;
  }

 public:
  intervalac(int n, vector<long long>& d) {
    int n2 = 1;
    while (n2 < n) n2 <<= 1;
    l.resize(n2 * 2 - 1);
    r.resize(n2 * 2 - 1);
    v.resize(n2 * 2 - 1, 0);
    lazy.resize(n2 * 2 - 1, 0);
    for (int i = n2 - 1; i < n2 * 2 - 1; i++) {
      l[i] = r[i] = i - (n2 - 1);
      if (i - (n2 - 1) < n) v[i] = d[i - (n2 - 1)];
    }
    for (int i = n2 - 2; i >= 0; i--) {
      v[i] = min(v[i * 2 + 1], v[i * 2 + 2]);
      l[i] = l[i * 2 + 1];
      r[i] = r[i * 2 + 2];
    }
  }
  long long mini(int li, int ri, int vr = 0) {
    if (li > r[vr] || ri < l[vr]) return 1e18;
    if (li <= l[vr] && r[vr] <= ri) return v[vr];
    unlazy(vr);
    return min(mini(li, ri, vr * 2 + 1), mini(li, ri, vr * 2 + 2));
  }
  void update(int li, int ri, int d, int vr = 0) {
    if (li > r[vr] || ri < l[vr]) return;
    if (li <= l[vr] && r[vr] <= ri) {
      v[vr] += d;
      lazy[vr] += d;
      return;
    }
    unlazy(vr);
    update(li, ri, d, vr * 2 + 1);
    update(li, ri, d, vr * 2 + 2);
    v[vr] = min(v[vr * 2 + 1], v[vr * 2 + 2]);
  }
};
vector<long long> d, ans, dt;
vector<int> t, l, r;
void dist(const vector<vector<pair<int, long long> > >& g, int v = 0,
          int p = -1, long long pd = 1e18) {
  t.push_back(v);
  dt.push_back(-pd);
  for (pair<int, long long> i : g[v]) {
    if (i.first != p) {
      d[i.first] = d[v] + i.second;
      dist(g, i.first, v, i.second);
      l[v] = min(l[i.first], l[v]);
      r[v] = max(r[i.first], r[v]);
    }
  }
  t.push_back(v);
  dt.push_back(pd);
  if (v == 0 || g[v].size() > 1) {
    d[v] = 1e18;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, q;
  cin >> n >> q;
  vector<vector<pair<int, long long> > > g(n);
  vector<vector<pair<int, pair<int, int> > > > qu(n);
  for (int i = 0; i < n - 1; i++) {
    int p;
    long long w;
    cin >> p >> w;
    g[p - 1].push_back({i + 1, w});
    g[i + 1].push_back({p - 1, w});
  }
  d.resize(n, 0);
  l.resize(n);
  r.resize(n);
  for (int i = 0; i < n; i++) l[i] = r[i] = i;
  ans.resize(q);
  dist(g);
  intervalac in(n, d);
  for (int i = 0; i < q; i++) {
    int v, l, r;
    cin >> v >> l >> r;
    qu[v - 1].push_back({i, {l - 1, r - 1}});
  }
  for (pair<int, pair<int, int> > j : qu[0]) {
    ans[j.first] = in.mini(j.second.first, j.second.second);
  }
  for (int i = 1; i < t.size(); i++) {
    in.update(l[t[i]], r[t[i]], +dt[i]);
    if (l[t[i]] > 0) in.update(0, l[t[i]] - 1, -dt[i]);
    if (r[t[i]] < n - 1) in.update(r[t[i]] + 1, n - 1, -dt[i]);
    if (dt[i] < 0) {
      for (pair<int, pair<int, int> > j : qu[t[i]]) {
        ans[j.first] = in.mini(j.second.first, j.second.second);
      }
    }
  }
  for (int i = 0; i < q; i++) {
    cout << ans[i] << "\n";
  }
  return 0;
}
