#include <bits/stdc++.h>
using namespace std;
const int N = 500001;
struct segment {
  long long tree[4 * N], lazy[4 * N];
  int n;
  void resize(int _n) { n = _n; }
  void shift(int l, int r, int node) {
    if (!lazy[node]) return;
    tree[node] += lazy[node];
    if (l != r) {
      lazy[node << 1] += lazy[node];
      lazy[node << 1 | 1] += lazy[node];
    }
    lazy[node] = 0;
  }
  void update(int l, int r, int node, int left, int right, long long val) {
    if (l > r) return;
    shift(l, r, node);
    if (l > right || r < left) return;
    if (l >= left && r <= right) {
      tree[node] += val;
      if (l != r) {
        lazy[node << 1] += val;
        lazy[node << 1 | 1] += val;
      }
      return;
    }
    int mid = (l + r) >> 1;
    update(l, mid, node << 1, left, right, val);
    update(mid + 1, r, node << 1 | 1, left, right, val);
    tree[node] = min(tree[node << 1], tree[node << 1 | 1]);
  }
  long long query(int l, int r, int node, int left, int right) {
    if (l > r) return 1e17;
    shift(l, r, node);
    if (l > right || r < left) return 1e17;
    if (l >= left && r <= right) return tree[node];
    int mid = (l + r) >> 1;
    return min(query(l, mid, node << 1, left, right),
               query(mid + 1, r, node << 1 | 1, left, right));
  }
};
struct query {
  int l, r, id;
};
int n, q, euler[N], mn[N], mx[N];
long long ans[N];
vector<pair<int, int> > v[N];
vector<query> s[N];
int id;
segment tree;
void dfs(int node, long long dist) {
  euler[node] = ++id;
  if (v[node].size() == 0) {
    mn[node] = mx[node] = id;
    tree.update(1, n, 1, id, id, dist);
  } else
    mn[node] = 1e9;
  for (auto &i : v[node]) {
    dfs(i.first, dist + i.second);
    mn[node] = min(mn[node], mn[i.first]);
    mx[node] = max(mx[node], mx[i.first]);
  }
}
void solve(int node) {
  for (auto &i : s[node]) ans[i.id] = tree.query(1, n, 1, i.l, i.r);
  for (auto &i : v[node]) {
    int l = mn[i.first], r = mx[i.first];
    tree.update(1, n, 1, l, r, -i.second);
    if (l != 1) tree.update(1, n, 1, 1, l - 1, i.second);
    if (r != n) tree.update(1, n, 1, r + 1, n, i.second);
    solve(i.first);
    tree.update(1, n, 1, l, r, i.second);
    if (l != 1) tree.update(1, n, 1, 1, l - 1, -i.second);
    if (r != n) tree.update(1, n, 1, r + 1, n, -i.second);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q;
  tree.resize(n);
  for (int i = 2, p, w; i <= n && cin >> p >> w; i++)
    v[p].push_back(make_pair(i, w));
  dfs(1, 0);
  for (int i = 1; i <= n; i++) {
    if (v[i].size()) {
      tree.update(1, n, 1, i, i, 1e17);
    }
  }
  for (int i = 0, v, l, r; i < q && cin >> v >> l >> r; i++)
    s[v].push_back({l, r, i});
  solve(1);
  for (int i = 0; i < q; i++) cout << ans[i] << '\n';
}
