#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 - '0' + c, c = getchar();
  x *= f;
}
const int N = 5e5 + 10;
const long long inf = 1e18;
long long mi[N << 2], tag[N << 2], dis[N], ans[N];
int isl[N], sz[N], n;
void push_up(int c) { mi[c] = min(mi[c << 1], mi[c << 1 | 1]); }
void Add(int c, long long qt) { tag[c] += qt, mi[c] += qt; }
void push_down(int c) {
  if (tag[c]) Add(c << 1, tag[c]), Add(c << 1 | 1, tag[c]), tag[c] = 0;
}
void build(int l, int r, int c) {
  if (l == r) {
    mi[c] = isl[l] ? dis[l] : inf;
    return;
  }
  int mid = l + r >> 1;
  build(l, mid, c << 1), build(mid + 1, r, c << 1 | 1);
  push_up(c);
}
int ql, qr;
long long qt;
void update(int l, int r, int c) {
  if (ql <= l && qr >= r) {
    Add(c, qt);
    return;
  }
  int mid = l + r >> 1;
  push_down(c);
  if (ql <= mid) update(l, mid, c << 1);
  if (qr > mid) update(mid + 1, r, c << 1 | 1);
  push_up(c);
}
long long ansmi;
void query(int l, int r, int c) {
  if (ql <= l && qr >= r) {
    ansmi = min(ansmi, mi[c]);
    return;
  }
  int mid = l + r >> 1;
  push_down(c);
  if (ql <= mid) query(l, mid, c << 1);
  if (qr > mid) query(mid + 1, r, c << 1 | 1);
}
struct ed {
  int to, w;
};
struct Que {
  int l, r, id;
};
vector<ed> G[N];
vector<Que> Q[N];
bool cmp(ed A, ed B) { return A.to < B.to; }
void dfs1(int u) {
  sz[u] = 1;
  for (int i = 0, siz = G[u].size(); i < siz; ++i) {
    int v = G[u][i].to;
    dis[v] = dis[u] + G[u][i].w;
    dfs1(v);
    sz[u] += sz[v];
  }
  isl[u] = G[u].size() == 0;
}
void work(int L, int R, int w) {
  ql = L, qr = R, qt = -w;
  update(1, n, 1);
  qt = w;
  if (L > 1) ql = 1, qr = L - 1, update(1, n, 1);
  if (R < n) ql = R + 1, qr = n, update(1, n, 1);
}
void dfs2(int u) {
  for (int i = 0, siz = Q[u].size(); i < siz; ++i) {
    ql = Q[u][i].l, qr = Q[u][i].r, ansmi = inf;
    query(1, n, 1);
    ans[Q[u][i].id] = ansmi;
  }
  for (int i = 0, siz = G[u].size(); i < siz; ++i) {
    int v = G[u][i].to;
    int L = v, R = v + sz[v] - 1;
    work(L, R, G[u][i].w);
    dfs2(v);
    work(L, R, -G[u][i].w);
  }
}
int main() {
  int x, w, l, r, v, q;
  read(n), read(q);
  for (int i = 2; i <= n; ++i) read(x), read(w), G[x].push_back((ed){i, w});
  for (int i = 1; i <= n; ++i)
    if (G[i].size()) sort(G[i].begin(), G[i].end(), cmp);
  for (int i = 1; i <= q; ++i)
    read(v), read(l), read(r), Q[v].push_back((Que){l, r, i});
  dfs1(1), build(1, n, 1), dfs2(1);
  for (int i = 1; i <= q; ++i) printf("%lld\n", ans[i]);
  return 0;
}
