#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
const long long inf = 0x3f3f3f3f3f3f3f3f;
inline void ckmax(int &a, int b) { a = max(a, b); }
inline void ckmin(int &a, int b) { a = min(a, b); }
int n, q, head[N], cnt, qhead[N], cntq, ql[N], qr[N], nxt[N], mn[N], mx[N];
long long dep[N], ans[N];
struct edge {
  int to, nxt, val;
} e[N << 1];
inline void add(int u, int v, int w) {
  e[++cnt] = (edge){v, head[u], w};
  head[u] = cnt;
}
inline void addq(int u) {
  nxt[cntq] = qhead[u];
  qhead[u] = ++cntq;
}
void dfs1(int u) {
  mn[u] = mx[u] = u;
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].to;
    dep[v] = dep[u] + e[i].val;
    dfs1(v);
    ckmax(mx[u], mx[v]);
    ckmin(mn[u], mn[v]);
  }
  if (head[u]) dep[u] = inf;
}
struct segment {
  int l, r;
  long long val, lzy;
} tr[N << 2];
inline void pushup(int p) {
  tr[p].val = min(tr[(p << 1)].val, tr[(p << 1 | 1)].val);
}
void build(int p, int l, int r) {
  tr[p].l = l, tr[p].r = r, tr[p].lzy = 0;
  if (l == r) {
    tr[p].val = dep[l];
    return;
  }
  int mid = l + r >> 1;
  build((p << 1), l, mid);
  build((p << 1 | 1), mid + 1, r);
  pushup(p);
}
inline void pushdown(int p) {
  long long &x = tr[p].lzy;
  if (x) {
    tr[(p << 1)].lzy += x, tr[(p << 1 | 1)].lzy += x;
    tr[(p << 1)].val += x, tr[(p << 1 | 1)].val += x;
    x = 0;
  }
}
void update(int p, int l, int r, int val) {
  if (tr[p].l >= l && tr[p].r <= r) {
    tr[p].lzy += val;
    tr[p].val += val;
    return;
  }
  pushdown(p);
  int mid = tr[p].l + tr[p].r >> 1;
  if (mid >= l) update((p << 1), l, r, val);
  if (mid < r) update((p << 1 | 1), l, r, val);
  pushup(p);
}
long long query(int p, int l, int r) {
  if (tr[p].l >= l && tr[p].r <= r) return tr[p].val;
  pushdown(p);
  int mid = tr[p].l + tr[p].r >> 1;
  long long ret = inf;
  if (mid >= l) ret = min(ret, query((p << 1), l, r));
  if (mid < r) ret = min(ret, query((p << 1 | 1), l, r));
  return ret;
}
void dfs2(int u) {
  for (int i = qhead[u]; i; i = nxt[i]) ans[i] = query(1, ql[i], qr[i]);
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].to, w = e[i].val;
    update(1, 1, n, w);
    update(1, mn[v], mx[v], -w * 2);
    dfs2(v);
    update(1, 1, n, -w);
    update(1, mn[v], mx[v], w * 2);
  }
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 2, u, w; i <= n; ++i) {
    scanf("%d%d", &u, &w);
    add(u, i, w);
  }
  for (int i = 1, u; i <= q; ++i) {
    scanf("%d%d%d", &u, &ql[i], &qr[i]);
    addq(u);
  }
  dfs1(1);
  for (int i = 1; i <= n; ++i)
    printf("dep = %lld, l = %d, r = %d\n", dep[i], mn[i], mx[i]);
  build(1, 1, n);
  dfs2(1);
  for (int i = 1; i <= q; ++i) printf("%lld\n", ans[i]);
  return 0;
}
