#include <bits/stdc++.h>
using namespace std;
long long n, q;
long long det[500005], ans[500005], arr[2000005], lazy[2000005];
vector<pair<long long, long long> > G[500005];
vector<array<long long, 3> > Q[500005];
void push_down(long long i, long long l, long long r) {
  if (lazy[i]) {
    arr[i] += lazy[i];
    if (l < r) lazy[2 * i] += lazy[i], lazy[2 * i + 1] += lazy[i];
    lazy[i] = 0;
  }
}
void push_up(long long i, long long l, long long r) {
  arr[i] = min(arr[2 * i], arr[2 * i + 1]);
}
void add(long long i, long long l, long long r, long long ll, long long rr,
         long long w) {
  push_down(i, l, r);
  if (l > rr or ll > r) return;
  if (ll <= l and r <= rr) {
    lazy[i] += w;
    push_down(i, l, r);
  } else {
    long long mid = l + r >> 1;
    add(2 * i, l, mid, ll, rr, w);
    add(2 * i + 1, mid + 1, r, ll, rr, w);
    push_up(i, l, r);
  }
}
long long ask(long long i, long long l, long long r, long long ll,
              long long rr) {
  push_down(i, l, r);
  if (l > rr or ll > r) return LLONG_MAX / 10000ll;
  if (ll <= l and r <= rr) {
    return arr[i];
  } else {
    long long mid = l + r >> 1;
    return min(ask(2 * i, l, mid, ll, rr), ask(2 * i + 1, mid + 1, r, ll, rr));
  }
}
void dfs(long long u, long long p, long long dist) {
  det[u] = u;
  if (G[u].size() > 1) {
    add(1, 1, n, u, u, LLONG_MAX / 10000ll);
  } else {
    add(1, 1, n, u, u, dist);
  }
  for (auto e : G[u]) {
    long long v = e.first, w = e.second;
    if (v - p) {
      dfs(v, u, dist + w);
      det[u] = max(det[u], det[v]);
    }
  }
}
void euler(long long u, long long p) {
  for (auto x : Q[u]) {
    ans[x[2]] = ask(1, 1, n, x[0], x[1]);
  }
  for (auto e : G[u]) {
    long long v = e.first, w = e.second;
    if (v - p) {
      add(1, 1, n, v, det[v], -w);
      if (1 <= v - 1) add(1, 1, n, 1, v - 1, w);
      if (det[v] + 1 <= n) add(1, 1, n, det[v] + 1, n, w);
      euler(v, u);
      add(1, 1, n, v, det[v], w);
      if (1 <= v - 1) add(1, 1, n, 1, v - 1, -w);
      if (det[v] + 1 <= n) add(1, 1, n, det[v] + 1, n, -w);
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> q;
  for (long long i = 2; i <= n; i++) {
    long long p, w;
    cin >> p >> w;
    G[p].emplace_back(i, w);
    G[i].emplace_back(p, w);
  }
  for (long long i = 1; i <= q; i++) {
    long long v, l, r;
    cin >> v >> l >> r;
    array<long long, 3> temp = {l, r, i};
    Q[v].emplace_back(temp);
  }
  dfs(1, 1, 0);
  euler(1, 1);
  for (long long i = 1; i <= q; i++) cout << ans[i] << "\n";
}
