#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
int n, q, out[N];
vector<pair<int, int>> g[N];
long long arr[N], ans[N], seg[4 * N], lzy[4 * N];
vector<pair<int, pair<int, int>>> queries[N];
int dfs(int u, long long dist) {
  out[u] = u;
  for (auto &c : g[u]) out[u] = max(out[u], dfs(c.first, dist + c.second));
  if (g[u].empty()) arr[u] = dist;
  return out[u];
}
void check(int p, int s, int e) {
  if (lzy[p]) {
    seg[p] += lzy[p];
    if (s != e) {
      lzy[p << 1] += lzy[p];
      lzy[p << 1 | 1] += lzy[p];
    }
    lzy[p] = 0;
  }
}
void update(int p, int s, int e, int l, int r, long long val) {
  check(p, s, e);
  if (s > r || e < l) return;
  if (s >= l && e <= r) {
    lzy[p] += val;
    check(p, s, e);
    return;
  }
  int m = s + e >> 1, a = p << 1, b = a | 1;
  update(a, s, m, l, r, val);
  update(b, m + 1, e, l, r, val);
  seg[p] = min(seg[a], seg[b]);
}
long long query(int p, int s, int e, int l, int r) {
  check(p, s, e);
  if (s > r || e < l) return 2e15;
  if (s >= l && e <= r) return seg[p];
  int m = s + e >> 1, a = p << 1, b = a | 1;
  return min(query(a, s, m, l, r), query(b, m + 1, e, l, r));
}
void solve(int u) {
  for (auto &it : queries[u]) {
    int idx = it.first, l = it.second.first, r = it.second.second;
    ans[idx] = query(1, 0, n, l, r);
  }
  for (auto &c : g[u]) {
    update(1, 0, n, 1, n, c.second);
    update(1, 0, n, c.first, out[c.first], -2 * c.second);
    solve(c.first);
    update(1, 0, n, 1, n, -c.second);
    update(1, 0, n, c.first, out[c.first], 2 * c.second);
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> q;
  for (int i = 2; i <= n; ++i) {
    int p, w;
    cin >> p >> w;
    g[p].emplace_back(i, w);
  }
  for (int i = 0; i < q; ++i) {
    int v, l, r;
    cin >> v >> l >> r;
    queries[v].push_back({i, {l, r}});
  }
  for (int i = 0; i < N; ++i) arr[i] = 2e15;
  dfs(1, 0);
  for (int i = 1; i <= n; ++i) update(1, 0, n, i, i, arr[i]);
  solve(1);
  for (int i = 0; i < q; ++i) cout << ans[i] << '\n';
  return 0;
}
