#include <bits/stdc++.h>
using namespace std;
const int N = 500010;
const int mod = 1e9 + 7;
long long ans[N];
int nxt[N], g[N], Ls[N];
int nex[N], l[N], r[N], la[N];
int d[N], v[N], w[N], n, q, e = 1, Q;
struct ST {
  struct node {
    long long min, lazy;
    int l, r;
  } T[N << 2];
  void build(int i, int l, int r) {
    T[i] = node{0, 0, l, r};
    if (l == r) {
      T[i].min = d[l];
      return;
    }
    int mid = (l + r) >> 1;
    build(i << 1, l, mid);
    build(i << 1 | 1, mid + 1, r);
    T[i].min = min(T[i << 1].min, T[i << 1 | 1].min);
  }
  void push_down(int i) {
    T[i << 1].lazy += T[i].lazy;
    T[i << 1 | 1].lazy += T[i].lazy;
    T[i << 1].min += T[i].lazy;
    T[i << 1 | 1].min += T[i].lazy;
    T[i].lazy = 0;
  }
  void update(int i, int l, int r, long long x) {
    if ((T[i].l == l) && (T[i].r == r)) {
      T[i].lazy += x;
      T[i].min += x;
      return;
    }
    if (T[i].lazy != 0) push_down(i);
    int mid = (T[i].l + T[i].r) >> 1;
    if (mid >= r)
      update(i << 1, l, r, x);
    else if (mid < l)
      update(i << 1 | 1, l, r, x);
    else {
      update(i << 1, l, mid, x);
      update(i << 1 | 1, mid + 1, r, x);
    }
    T[i].min = min(T[i << 1].min, T[i << 1 | 1].min);
  }
  long long getmin(int i, int l, int r) {
    if ((T[i].l == l) && (T[i].r == r)) return T[i].min;
    if (T[i].lazy != 0) push_down(i);
    int mid = (T[i].l + T[i].r) >> 1;
    if (mid >= r)
      return getmin(i << 1, l, r);
    else if (mid < l)
      return getmin(i << 1 | 1, l, r);
    else
      return min(getmin(i << 1, l, mid), getmin(i << 1 | 1, mid + 1, r));
  }
} seg;
inline void addedge(int x, int y) {
  g[++e] = y;
  nxt[e] = Ls[x];
  Ls[x] = e;
}
inline void addquery(int x, int L, int R) {
  l[++Q] = L;
  r[Q] = R;
  nex[Q] = la[x];
  la[x] = Q;
}
inline void update(int x, int d) {
  seg.update(1, 1, n, d);
  seg.update(1, x, v[x], -(d << 1));
}
void dfs(int x) {
  update(x, w[x]);
  for (int i = la[x]; i; i = nex[i]) ans[i] = seg.getmin(1, l[i], r[i]);
  for (int i = Ls[x]; i; i = nxt[i]) dfs(g[i]);
  update(x, -w[x]);
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; i++) {
    int y = i, x;
    scanf("%d%d", &x, &w[i]);
    d[y] = d[x] + w[i];
    addedge(x, y);
  }
  for (int i = n; i; i--)
    if (Ls[i])
      v[i] = v[Ls[i]], d[i] = 1 << 60;
    else
      v[i] = i;
  for (int i = 1; i <= q; i++) {
    int x, l, r;
    scanf("%d%d%d", &x, &l, &r);
    addquery(x, l, r);
  }
  seg.build(1, 1, n);
  dfs(1);
  for (int i = 1; i <= q; i++) printf("%lld\n", ans[i]);
  return 0;
}
