#include <bits/stdc++.h>
using namespace std;
long long inf = 1e16;
long long tree[4 * 500005 + 1], lo[4 * 500005 + 1], hi[4 * 500005 + 1],
    a[500005], delta[4 * 500005 + 1], dist[500005], rright[500005],
    lleft[500005], ans[500005], n;
vector<pair<pair<long long, long long>, long long>> q[500005];
vector<pair<long long, long long>> adj[500005];
void init(long long i, long long a, long long b) {
  lo[i] = a;
  hi[i] = b;
  if (a == b) return;
  long long m = (a + b) / 2;
  init(2 * i, a, m);
  init(2 * i + 1, m + 1, b);
}
void merge(long long i0, long long i1, long long i2) {
  tree[i0] = min(tree[i1] + delta[i1], tree[i2] + delta[i2]);
}
void build(long long i) {
  long long l = lo[i];
  long long r = hi[i];
  if (l == r) {
    tree[i] = dist[l];
    return;
  }
  build(2 * i);
  build(2 * i + 1);
  merge(i, 2 * i, 2 * i + 1);
}
void prop(long long i) {
  delta[2 * i] += delta[i];
  delta[2 * i + 1] += delta[i];
  delta[i] = 0;
}
void increment(long long i, long long a, long long b, long long val) {
  if (b < lo[i] || hi[i] < a) return;
  if (a <= lo[i] && hi[i] <= b) {
    delta[i] += val;
    return;
  }
  prop(i);
  increment(2 * i, a, b, val);
  increment(2 * i + 1, a, b, val);
  merge(i, 2 * i, 2 * i + 1);
}
long long query(long long i, long long l, long long r) {
  if (r < lo[i] || hi[i] < l) {
    return inf;
  }
  if (l <= lo[i] && hi[i] <= r) {
    return tree[i] + delta[i];
  }
  prop(i);
  long long minr = query(2 * i, l, r);
  long long minl = query(2 * i + 1, l, r);
  merge(i, 2 * i, 2 * i + 1);
  return min(minr, minl);
}
void dfs1(long long u, long long dis) {
  lleft[u] = inf;
  if (adj[u].empty()) {
    dist[u] = dis;
    lleft[u] = u;
    rright[u] = u;
    return;
  }
  for (auto k : adj[u]) {
    dfs1(k.first, dis + k.second);
    lleft[u] = min(lleft[u], lleft[k.first]);
    rright[u] = max(rright[u], rright[k.first]);
  }
}
void calc(long long u) {
  for (auto k : q[u]) {
    ans[k.second] = query(1, k.first.first, k.first.second);
  }
  for (auto k : adj[u]) {
    increment(1, lleft[k.first], rright[k.first], -2 * k.second);
    increment(1, 1, n, k.second);
    calc(k.first);
    increment(1, lleft[k.first], rright[k.first], +2 * k.second);
    increment(1, 1, n, -k.second);
  }
}
int main() {
  ios::sync_with_stdio(false);
  long long Q;
  cin >> n >> Q;
  for (long long i = 2; i <= n; i++) {
    long long x, w;
    cin >> x >> w;
    adj[x].push_back({i, w});
  }
  for (long long i = 0; i < Q; i++) {
    long long l1, r1, v;
    cin >> v >> l1 >> r1;
    q[v].push_back({{l1, r1}, i});
  }
  dfs1(1, 0);
  for (long long i = 1; i <= n; i++) {
    if (!dist[i]) dist[i] = inf;
  }
  init(1, 1, n);
  build(1);
  calc(1);
  for (long long i = 0; i < Q; i++) cout << ans[i] << "\n";
}
