#include <bits/stdc++.h>
using namespace std;
const int Max_N(500050);
const int Max_Q(500050);
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;
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::gi;
using io::print;
using io::putc;
struct edge {
  edge(int _t, int _w) : t(_t), w(_w) {}
  int t, w;
  inline bool operator<(const edge &b) const { return t < b.t; }
};
int N, Q, dfsclock, Pre[Max_N], Post[Max_N], L[Max_Q], R[Max_Q];
long long int Dist[Max_N], Ans[Max_Q];
vector<edge> Son[Max_N];
vector<int> A[Max_N];
void dfs(int u) {
  Pre[u] = ++dfsclock;
  sort(Son[u].begin(), Son[u].end());
  for (int i = 0, v, w; i < Son[u].size(); ++i)
    v = Son[u][i].t, w = Son[u][i].w, Dist[v] = Dist[u] + w, dfs(v);
  Post[u] = dfsclock;
}
struct node {
  int l, r, mid;
  long long int Tag, Min;
};
node segt[Max_N << 2];
inline void pushup(int cur) {
  (segt[cur].Min) = min(segt[(cur << 1)].Min, segt[((cur << 1) | 1)].Min);
}
inline void insert(int cur, long long int v) {
  (segt[cur].Tag) += v, (segt[cur].Min) += v;
}
inline void pushdown(int cur) {
  if ((segt[cur].Tag))
    insert((cur << 1), (segt[cur].Tag)),
        insert(((cur << 1) | 1), (segt[cur].Tag)), (segt[cur].Tag) = 0LL;
}
void build_tree(int cur, int l, int r) {
  (segt[cur].mid) = l + ((r - l) >> 1), (segt[cur].Tag) = 0LL;
  if (((segt[cur].l) = l) == ((segt[cur].r) = r)) {
    int u = Pre[(segt[cur].mid)];
    (segt[cur].Min) = (Son[u].empty() ? Dist[u] : 0X3F3F3F3F3F3F3F3FLL);
    return;
  }
  build_tree((cur << 1), l, (segt[cur].mid)),
      build_tree(((cur << 1) | 1), (segt[cur].mid) + 1, r), pushup(cur);
}
void insert(int cur, int l, int r, long long int v) {
  if ((segt[cur].l) == l && (segt[cur].r) == r) {
    insert(cur, v);
    return;
  }
  pushdown(cur);
  if (r <= (segt[cur].mid))
    insert((cur << 1), l, r, v);
  else if (l > (segt[cur].mid))
    insert(((cur << 1) | 1), l, r, v);
  else
    insert((cur << 1), l, (segt[cur].mid), v),
        insert(((cur << 1) | 1), (segt[cur].mid) + 1, r, v);
  pushup(cur);
}
long long int query(int cur, int l, int r) {
  if ((segt[cur].l) == l && (segt[cur].r) == r) return (segt[cur].Min);
  pushdown(cur);
  if (r <= (segt[cur].mid))
    return query((cur << 1), l, r);
  else if (l > (segt[cur].mid))
    return query(((cur << 1) | 1), l, r);
  else
    return min(query((cur << 1), l, (segt[cur].mid)),
               query(((cur << 1) | 1), (segt[cur].mid) + 1, r));
}
void work(int u) {
  for (int i = 0, p; i < A[u].size(); ++i)
    p = A[u][i], Ans[p] = query(1, L[p], R[p]);
  for (int i = 0, v, w; i < Son[u].size(); ++i)
    v = Son[u][i].t, w = Son[u][i].w, insert(1, +w),
    insert(1, Pre[v], Post[v], -2LL * w), work(v),
    insert(1, Pre[v], Post[v], +2LL * w), insert(1, -w);
}
int main() {
  gi(N), gi(Q);
  for (int i = 2, fa, w; i <= N; ++i)
    gi(fa), gi(w), Son[fa].push_back(edge(i, w));
  for (int i = 1, u; i <= Q; ++i) gi(u), gi(L[i]), gi(R[i]), A[u].push_back(i);
  dfs(1);
  build_tree(1, 1, dfsclock);
  work(1);
  for (int i = 1; i <= Q; ++i) print(Ans[i]), putc('\n');
  return 0;
}
