#include <bits/stdc++.h>
using namespace std;
namespace io {
const int SIZE = (1 << 21) + 1;
char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c,
                                       qu[55];
int f, qr;
char getc() {
  return (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                      (iS == iT ? EOF : *iS++))
                   : *iS++);
}
inline void flush() {
  fwrite(obuf, 1, oS - obuf, stdout);
  oS = obuf;
}
inline void putc(char x) {
  *oS++ = x;
  if (oS == oT) flush();
}
template <class I>
inline void gi(I &x) {
  for (f = 1, c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                              (iS == iT ? EOF : *iS++))
                            : *iS++);
       c < '0' || c > '9';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    if (c == '-') f = -1;
  for (x = 0; c <= '9' && c >= '0';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    x = x * 10 + (c & 15);
  x *= f;
}
template <class I>
inline void print(I x) {
  if (!x) putc('0');
  if (x < 0) putc('-'), x = -x;
  while (x) qu[++qr] = x % 10 + '0', x /= 10;
  while (qr) putc(qu[qr--]);
}
struct Flusher_ {
  ~Flusher_() { flush(); }
} io_flusher_;
}  // namespace io
using io ::getc;
using io ::gi;
using io ::print;
using io ::putc;
const int N = 500005;
const long long INF = 1000000000000000000;
struct Edge {
  int v, w;
};
struct Query {
  int l, r, id;
};
vector<Edge> G[N];
vector<Query> Q[N];
long long res[N];
int n;
long long dis[N];
long long mn[N * 4], tag[N * 4];
void build(int x, int l, int r) {
  if (l == r) {
    mn[x] = dis[l];
    return;
  }
  int mid = (l + r) >> 1;
  build(x << 1, l, mid);
  build(x << 1 | 1, mid + 1, r);
  mn[x] = min(mn[x << 1], mn[x << 1 | 1]);
}
void modify(int x, int l, int r, int ql, int qr, int d) {
  if (ql <= l && r <= qr) {
    tag[x] += d, mn[x] += d;
    return;
  }
  int mid = (l + r) >> 1;
  if (ql <= mid) modify(x << 1, l, mid, ql, qr, d);
  if (qr > mid) modify(x << 1 | 1, mid + 1, r, ql, qr, d);
  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 && r <= qr) return mn[x];
  int mid = (l + r) >> 1;
  long long res = INF;
  if (ql <= mid) res = min(res, query(x << 1, l, mid, ql, qr));
  if (qr > mid) res = min(res, query(x << 1 | 1, mid + 1, r, ql, qr));
  return res + tag[x];
}
int R[N];
void dfs(int x) {
  R[x] = x;
  for (Edge e : G[x]) {
    dis[e.v] = dis[x] + e.w;
    dfs(e.v);
    R[x] = max(R[x], R[e.v]);
  }
  if (R[x] != x) dis[x] = INF;
}
void solve(int x) {
  for (const Query &q : Q[x]) res[q.id] = query(1, 1, n, q.l, q.r);
  for (Edge e : G[x]) {
    modify(1, 1, n, e.v, R[e.v], -e.w - e.w);
    mn[1] += e.w;
    tag[1] += e.w;
    solve(e.v);
    modify(1, 1, n, e.v, R[e.v], e.w << 1);
    mn[1] -= e.w;
    tag[1] -= e.w;
  }
}
int main() {
  int q;
  gi(n);
  gi(q);
  for (int i = 2; i <= n; i++) {
    int fa, w;
    gi(fa);
    gi(w);
    G[fa].push_back({i, w});
  }
  for (int i = 1; i <= q; i++) {
    int x, l, r;
    gi(x);
    gi(l);
    gi(r);
    Q[x].push_back({l, r, i});
  }
  dfs(1);
  build(1, 1, n);
  solve(1);
  for (int i = 1; i <= q; i++) print(res[i]), putc('\n');
  return 0;
}
