#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5 * 100100;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
int n, q, curt, tin[MAXN], tout[MAXN];
long long lv[MAXN], ans[MAXN];
vector<pair<int, int>> g[MAXN];
vector<tuple<int, int, int>> qr[MAXN];
struct no {
  int beg, end, mid;
  long long mn, lz;
  no *l, *r;
  no(int beg, int end, long long v[])
      : beg(beg), end(end), mid((beg + end) >> 1), lz(0), mn(v[beg]) {
    if (beg != end)
      l = new no(beg, mid, v), r = new no(mid + 1, end, v),
      mn = min(l->mn, r->mn);
  }
  void refresh() {
    mn += lz;
    if (beg != end) l->lz += lz, r->lz += lz;
    lz = 0;
  }
  void upd(int a, int b, long long inc) {
    if (b < beg || end < a) return;
    if (a <= beg && end <= b) return lz += inc, refresh();
    refresh();
    l->upd(a, b, inc), r->upd(a, b, inc);
    mn = min(l->mn, r->mn);
  }
  long long get(int a, int b) {
    if (b < beg || end < a) return LINF;
    refresh();
    if (a <= beg && end <= b) return mn;
    return min(l->get(a, b), r->get(a, b));
  }
};
void dfs(int v, long long dist = 0) {
  tin[v] = ++curt;
  lv[curt] = (g[v].empty() ? dist : LINF);
  for (const auto &[u, w] : g[v]) dfs(u, dist + w);
  tout[v] = curt;
}
void solve(int v, no &seg, long long acc = 0) {
  for (const auto &[l, r, id] : qr[v]) ans[id] = seg.get(l, r) + acc;
  for (const auto &[u, w] : g[v]) {
    seg.upd(1, tin[u] - 1, w);
    seg.upd(tin[u], tout[u], -w);
    seg.upd(tout[u] + 1, curt, w);
    solve(u, seg, acc);
    seg.upd(1, tin[u] - 1, -w);
    seg.upd(tin[u], tout[u], w);
    seg.upd(tout[u] + 1, curt, -w);
  }
}
int main() {
  scanf("%d %d", &n, &q);
  for (int i = 2, p, w; i <= n; ++i)
    scanf("%d %d", &p, &w), g[p].emplace_back(i, w);
  for (int i = 1; i <= n; ++i) sort(g[i].begin(), g[i].end());
  dfs(1);
  no seg(1, curt, lv);
  for (int i = 1, v, l, r; i <= q; ++i)
    scanf("%d %d %d", &v, &l, &r), qr[v].emplace_back(l, r, i);
  solve(1, seg);
  for (int i = 1; i <= q; ++i) printf("%lld\n", ans[i]);
}
