#include <bits/stdc++.h>
using namespace std;
const int maxn(5e5 + 5);
const long long inf(1e18);
struct Qry {
  int l, r, id;
};
int n, q, dfn[maxn], idx, ed[maxn];
long long mn[maxn << 2], tag[maxn << 2], ans[maxn];
vector<pair<int, int> > edge[maxn];
vector<Qry> qry[maxn];
void Update(int x, int l, int r, int p, long long v) {
  if (l == r)
    mn[x] = v + tag[x];
  else {
    int mid = (l + r) >> 1;
    p <= mid ? Update(x << 1, l, mid, p, v)
             : Update(x << 1 | 1, mid + 1, r, p, v);
    mn[x] = min(mn[x << 1], mn[x << 1 | 1]) + tag[x];
  }
}
void Modify(int x, int l, int r, int ql, int qr, long long v) {
  if (ql <= l && qr >= r)
    tag[x] += v, mn[x] += v;
  else {
    int mid = (l + r) >> 1;
    if (ql <= mid) Modify(x << 1, l, mid, ql, qr, v);
    if (qr > mid) Modify(x << 1 | 1, mid + 1, r, ql, qr, v);
    mn[x] = min(mn[x << 1], mn[x << 1 | 1]) + tag[x];
  }
}
long long Query(int x, int l, int r, int ql, int qr) {
  if (ql <= l && qr >= r) return mn[x];
  int mid = (l + r) >> 1;
  long long ret = inf;
  if (ql <= mid) ret = Query(x << 1, l, mid, ql, qr);
  if (qr > mid) ret = min(ret, Query(x << 1 | 1, mid + 1, r, ql, qr));
  return ret + tag[x];
}
void Dfs1(int u, long long d) {
  dfn[u] = ++idx;
  if (!edge[u].size()) Update(1, 1, n, idx, d);
  for (auto v : edge[u]) Dfs1(v.first, d + v.second);
  ed[u] = idx;
}
void Dfs2(int u) {
  for (auto ques : qry[u]) ans[ques.id] = Query(1, 1, n, ques.l, ques.r);
  for (auto v : edge[u]) {
    Modify(1, 1, n, 1, n, v.second);
    Modify(1, 1, n, dfn[v.first], ed[v.first], -(v.second << 1));
    Dfs2(v.first);
    Modify(1, 1, n, dfn[v.first], ed[v.first], v.second << 1);
    Modify(1, 1, n, 1, n, -v.second);
  }
}
int main() {
  memset(mn, 63, sizeof(mn));
  int p, w, i, l, r;
  scanf("%d%d", &n, &q);
  for (i = 2; i <= n; ++i) {
    scanf("%d%d", &p, &w);
    edge[p].push_back(make_pair(i, w));
  }
  for (i = 1; i <= q; ++i) {
    scanf("%d%d%d", &p, &l, &r);
    qry[p].push_back((Qry){l, r, i});
  }
  Dfs1(1, 0), Dfs2(1);
  for (i = 1; i <= q; ++i) printf("%lld\n", ans[i]);
  return 0;
}
