#include <bits/stdc++.h>
using namespace std;
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
inline long long msbp(long long x) { return 31 - __builtin_clz(x); }
inline long long msb(long long x) { return 1 << msbp(x); }
const long long INF = 0x3f3f3f3f;
const long long inf = 1e15;
struct Node {
  Node *l = 0, *r = 0;
  long long lo, hi, mset = inf, madd = 0, val = inf;
  Node(long long lo, long long hi) : lo(lo), hi(hi) {}
  Node(vector<long long>& v, long long lo, long long hi) : lo(lo), hi(hi) {
    if (lo + 1 < hi) {
      long long mid = lo + (hi - lo) / 2;
      l = new Node(v, lo, mid);
      r = new Node(v, mid, hi);
      val = min(l->val, r->val);
    } else
      val = v[lo];
  }
  long long query(long long L, long long R) {
    if (R <= lo || hi <= L) return inf;
    if (L <= lo && hi <= R) return val;
    push();
    return min(l->query(L, R), r->query(L, R));
  }
  void set(long long L, long long R, long long x) {
    if (R <= lo || hi <= L) return;
    if (L <= lo && hi <= R)
      mset = val = x, madd = 0;
    else {
      push(), l->set(L, R, x), r->set(L, R, x);
      val = min(l->val, r->val);
    }
  }
  void add(long long L, long long R, long long x) {
    if (R <= lo || hi <= L) return;
    if (L <= lo && hi <= R) {
      if (mset != inf)
        mset += x;
      else
        madd += x;
      val += x;
    } else {
      push(), l->add(L, R, x), r->add(L, R, x);
      val = min(l->val, r->val);
    }
  }
  void push() {
    if (!l) {
      long long mid = lo + (hi - lo) / 2;
      l = new Node(lo, mid);
      r = new Node(mid, hi);
    }
    if (mset != inf)
      l->set(lo, hi, mset), r->set(lo, hi, mset), mset = inf;
    else if (madd)
      l->add(lo, hi, madd), r->add(lo, hi, madd), madd = 0;
  }
};
const long long N = 5e5 + 10;
long long n, q, ans[N], nxt[N];
vector<pair<long long, long long> > g[N];
vector<long long> d;
Node tree(0, 1);
struct query {
  long long id, l, r;
};
vector<query> qs[N];
void dfs(long long s) {
  long long k = g[s].size();
  g[s].push_back({nxt[s], 0});
  for (long long i = 0; i < (k); ++i) {
    auto [v, w] = g[s][i];
    d[v] = d[s] + w;
    nxt[v] = g[s][i + 1].first;
    dfs(v);
  }
  g[s].pop_back();
  if (k) d[s] = inf;
}
void answer(long long s) {
  for (auto cur : qs[s]) {
    ans[cur.id] = tree.query(cur.l, cur.r + 1);
  }
  long long k = g[s].size();
  for (long long i = 0; i < (k); ++i) {
    long long v = g[s][i].first, w = g[s][i].second;
    long long v2 = nxt[v];
    tree.add(v, v2, -w);
    tree.add(1, v, w);
    tree.add(v2, n + 1, w);
    answer(v);
    tree.add(v, v2, w);
    tree.add(1, v, -w);
    tree.add(v2, n + 1, -w);
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin >> n >> q;
  for (long long i = (2); i <= (n); ++i) {
    long long p, w;
    cin >> p >> w;
    g[p].push_back({i, w});
  }
  for (long long i = 0; i < (q); ++i) {
    query cur;
    long long v;
    cin >> v >> cur.l >> cur.r;
    cur.id = i;
    qs[v].push_back(cur);
  }
  d.resize(n + 1, 0);
  nxt[1] = n + 1;
  dfs(1);
  tree = Node(d, 1, n + 1);
  answer(1);
  for (long long i = 0; i < (q); ++i) cout << ans[i] << endl;
  return 0;
}
