#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll kInf = 1e18;
const int kNmax = 5e5 + 5;
struct aintt {
  ll value;
  ll lazy;
};
aintt aint[kNmax * 4];
void aint_update(int n, int l, int r, int ql, int qr, ll add) {
  if (ql > qr) return;
  if (r < ql || qr < l) return;
  if (ql <= l && r <= qr) {
    aint[n].lazy += add;
    return;
  }
  int m = (l + r) / 2;
  aint[2 * n].lazy += aint[n].lazy;
  aint[2 * n + 1].lazy += aint[n].lazy;
  aint[n].lazy = 0;
  aint_update(2 * n, l, m, ql, qr, add);
  aint_update(2 * n + 1, m + 1, r, ql, qr, add);
  aint[n].value = min(aint[2 * n].value + aint[2 * n].lazy,
                      aint[2 * n + 1].value + aint[2 * n + 1].lazy);
}
ll aint_query(int n, int l, int r, int ql, int qr) {
  if (r < ql || qr < l || ql > qr) return kInf;
  aint[n].value += aint[n].lazy;
  if (l != r) {
    aint[2 * n].lazy += aint[n].lazy;
    aint[2 * n + 1].lazy += aint[n].lazy;
  }
  aint[n].lazy = 0;
  if (ql <= l && r <= qr) {
    return aint[n].value;
  }
  int m = (l + r) / 2;
  return min(aint_query(2 * n, l, m, ql, qr),
             aint_query(2 * n + 1, m + 1, r, ql, qr));
}
vector<tuple<int, int, int> > queries[kNmax];
int first[kNmax];
int last[kNmax];
int euler[kNmax];
vector<pair<int, ll> > g[kNmax];
ll dist[kNmax];
ll sol[kNmax];
int n, q;
void aint_build(int n, int l, int r) {
  aint[n].lazy = 0;
  if (l == r) {
    aint[n].value = dist[euler[l]];
    return;
  }
  int m = (l + r) / 2;
  aint_build(2 * n, l, m);
  aint_build(2 * n + 1, m + 1, r);
  aint[n].value = min(aint[2 * n].value, aint[2 * n + 1].value);
}
int dfs_next_id = 1;
void dfs_euler(int x) {
  euler[dfs_next_id] = x;
  first[x] = dfs_next_id++;
  int leaf = 1;
  for (auto& yd : g[x]) {
    auto y = yd.first;
    auto d = yd.second;
    leaf = 0;
    dist[y] = dist[x] + d;
    dfs_euler(y);
  }
  if (!leaf) dist[x] = kInf;
  last[x] = dfs_next_id;
}
void dfs_sol(int x) {
  for (auto& tup : queries[x]) {
    int l, r, i;
    tie(l, r, i) = tup;
    sol[i] = aint_query(1, 1, n, l, r);
  }
  for (auto& yd : g[x]) {
    auto y = yd.first;
    auto d = yd.second;
    aint_update(1, 1, n, first[y], last[y] - 1, -d);
    aint_update(1, 1, n, 1, first[y] - 1, d);
    aint_update(1, 1, n, last[y], n, d);
    dfs_sol(y);
    aint_update(1, 1, n, first[y], last[y] - 1, d);
    aint_update(1, 1, n, 1, first[y] - 1, -d);
    aint_update(1, 1, n, last[y], n, -d);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> q;
  for (int i = 2; i <= n; i++) {
    int p;
    ll d;
    cin >> p >> d;
    g[p].push_back(make_pair(i, d));
  }
  dfs_euler(1);
  aint_build(1, 1, n);
  for (int i = 1; i <= q; i++) {
    int v, l, r;
    cin >> v >> l >> r;
    queries[v].push_back(make_tuple(l, r, i));
  }
  dfs_sol(1);
  for (int i = 1; i <= q; i++) {
    cout << sol[i] << '\n';
  }
  return 0;
}
