#include <bits/stdc++.h>
using namespace std;
const int NR = 501000;
struct Edge {
  int y, frt, w;
} g[NR << 1];
int pos[NR], bg[NR], ed[NR], dsz, out[NR], n, q, son[NR], top[NR], gsz, L[NR],
    fa[NR];
long long dep[NR], ans[NR];
void AE(int x, int y, int z) { g[++gsz] = (Edge){y, pos[x], z}, pos[x] = gsz; }
vector<pair<int, long long> > ss[NR << 2], st[NR << 2], qr[NR];
const long long inf = 1e17;
void push(vector<pair<int, long long> > &q, int p, long long w) {
  while (!q.empty() && q.back().second >= w) {
    q.pop_back();
  }
  q.push_back(pair<int, long long>(p, w));
}
long long qvec(vector<pair<int, long long> > &q, int l) {
  if (q.empty()) return inf;
  auto it = lower_bound(q.begin(), q.end(), pair<int, long long>(l, 0));
  if (it == q.end())
    return inf;
  else
    return it->second;
}
void seg_ins(int x, int l, int r, int ml, int mr, int ii, long long w) {
  if (ml <= l && r <= mr) {
    push(ss[x], ii, w);
    return;
  }
  int mid = (l + r) / 2;
  if (ml <= mid) seg_ins(x << 1, l, mid, ml, mr, ii, w);
  if (mr > mid) seg_ins(x << 1 | 1, mid + 1, r, ml, mr, ii, w);
}
void seg_modi(int x, int l, int r, int ml, int mr, int ii, long long w) {
  if (ml <= l && r <= mr) {
    push(st[x], ii, w);
    return;
  }
  int mid = (l + r) / 2;
  if (ml <= mid) seg_modi(x << 1, l, mid, ml, mr, ii, w);
  if (mr > mid) seg_modi(x << 1 | 1, mid + 1, r, ml, mr, ii, w);
}
long long seg_qset(int x, int l, int r, int p, int ii) {
  if (l == r) {
    return qvec(ss[x], ii);
  }
  int mid = (l + r) / 2;
  long long t = qvec(ss[x], ii);
  if (p <= mid)
    return min(t, seg_qset(x << 1, l, mid, p, ii));
  else
    return min(t, seg_qset(x << 1 | 1, mid + 1, r, p, ii));
}
long long seg_qmin(int x, int l, int r, int p, int ii) {
  if (l == r) {
    return qvec(st[x], ii);
  }
  int mid = (l + r) / 2;
  long long t = qvec(st[x], ii);
  if (p <= mid)
    return min(t, seg_qmin(x << 1, l, mid, p, ii));
  else
    return min(t, seg_qmin(x << 1 | 1, mid + 1, r, p, ii));
}
void modify(int x) {
  int _x = x, bd = dep[x];
  seg_ins(1, 1, n, bg[x], ed[x], x, -dep[x]);
  while (x) {
    seg_modi(1, 1, n, bg[top[x]], bg[x], _x, dep[_x]);
    if (fa[top[x]])
      seg_ins(1, 1, n, bg[fa[top[x]]], bg[top[x]] - 1, _x,
              dep[_x] - 2 * dep[fa[top[x]]]);
    x = fa[top[x]];
  }
}
void dfs(int x) {
  for (int i = pos[x]; i; i = g[i].frt) {
    dep[g[i].y] = dep[x] + g[i].w;
    dfs(g[i].y);
  }
}
long long query(int x, int l) {
  int _x = x;
  long long ans = seg_qset(1, 1, n, bg[x], l) + dep[x];
  while (x) {
    if (fa[top[x]])
      ans = min(ans, seg_qmin(1, 1, n, bg[fa[top[x]]], l) + dep[_x] -
                         2 * dep[fa[top[x]]]);
    x = fa[top[x]];
  }
  return ans;
}
void bt(int x, int tp) {
  top[x] = tp;
  bg[x] = ++dsz;
  if (son[x]) bt(son[x], tp);
  for (int i = pos[x]; i; i = g[i].frt)
    if (g[i].y != son[x]) bt(g[i].y, g[i].y);
  ed[x] = dsz;
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; ++i) {
    int p, w;
    scanf("%d%d", &p, &w);
    fa[i] = p;
    AE(p, i, w);
    out[p]++;
  }
  dfs(1);
  bt(1, 1);
  for (int i = 1; i <= q; ++i) {
    int v, l, r;
    scanf("%d%d%d", &v, &l, &r);
    qr[r].push_back(pair<int, long long>(v, i));
    L[i] = l;
  }
  for (int i = 1; i <= n; ++i) {
    if (out[i] == 0) modify(i);
    for (pair<int, long long> qq : qr[i])
      ans[qq.second] = query(qq.first, L[qq.second]);
  }
  for (int i = 1; i <= q; ++i) printf("%lld\n", ans[i]);
  return 0;
}
