#include <bits/stdc++.h>
using namespace std;
long long n, m, tot, l[500010], r[500010], Max[500010];
long long head[500010], ver[500010], Next[500010], edge[500010];
long long Min[500010 << 2], mark[500010 << 2], d[500010], ans[500010];
vector<long long> q[500010];
inline void pushup(long long p) { Min[p] = min(Min[p << 1], Min[p << 1 | 1]); }
inline void pushdown(long long p) {
  if (!mark[p]) return;
  long long v = mark[p];
  Min[p << 1] += v;
  mark[p << 1] += v;
  Min[p << 1 | 1] += v;
  mark[p << 1 | 1] += v;
  mark[p] = 0;
}
void build(long long L, long long R, long long p, long long l, long long r,
           long long v) {
  if (L <= l && r <= R) {
    Min[p] += v;
    mark[p] += v;
    return;
  }
  pushdown(p);
  long long mid = (l + r) >> 1;
  if (L <= mid) build(L, R, p << 1, l, mid, v);
  if (mid < R) build(L, R, p << 1 | 1, mid + 1, r, v);
  pushup(p);
}
long long query(long long L, long long R, long long p, long long l,
                long long r) {
  if (L <= l && r <= R) return Min[p];
  pushdown(p);
  long long mid = (l + r) >> 1, ans = 0x7ffffffff;
  if (L <= mid) ans = min(ans, query(L, R, p << 1, l, mid));
  if (mid < R) ans = min(ans, query(L, R, p << 1 | 1, mid + 1, r));
  return ans;
}
inline void addEdge(long long u, long long v, long long w) {
  ver[++tot] = v;
  edge[tot] = w;
  Next[tot] = head[u];
  head[u] = tot;
}
void dfs1(long long u) {
  Max[u] = u;
  for (long long i = head[u]; i; i = Next[i]) {
    long long v = ver[i];
    d[v] = d[u] + edge[i];
    dfs1(v);
    Max[u] = max(Max[u], Max[v]);
  }
}
void dfs2(long long u) {
  for (long long i : q[u]) ans[i] = query(l[i], r[i], 1, 1, n);
  for (long long i = head[u]; i; i = Next[i]) {
    long long v = ver[i], w = edge[i];
    build(1, n, 1, 1, n, w);
    build(v, Max[v], 1, 1, n, -w - w);
    dfs2(v);
    build(1, n, 1, 1, n, -w);
    build(v, Max[v], 1, 1, n, w + w);
  }
}
int main() {
  scanf("%lld %lld", &n, &m);
  for (long long i = 2; i <= n; i++) {
    long long p, w;
    scanf("%lld %lld", &p, &w);
    addEdge(p, i, w);
  }
  dfs1(1);
  for (long long i = 1; i <= n; i++) {
    build(i, i, 1, 1, n, i == Max[i] ? d[i] : 0x7ffffffff);
  }
  for (long long i = 1; i <= m; i++) {
    long long v;
    scanf("%lld %lld %lld", &v, &l[i], &r[i]);
    q[v].push_back(i);
  }
  dfs2(1);
  for (long long i = 1; i <= m; i++) printf("%lld\n", ans[i]);
  return 0;
}
