#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<long long, long long> > > adj;
vector<vector<pair<long long, pair<long long, long long> > > > que;
long long temp = 0;
vector<long long> idx;
vector<long long> res;
vector<long long> arr;
vector<long long> tree;
vector<long long> lazy;
long long n;
void constructST(long long si, long long s, long long e) {
  if (s == e) {
    tree[si] = arr[s];
    return;
  }
  long long mid = (s + e) / 2;
  constructST(2 * si + 1, s, mid);
  constructST(2 * si + 2, mid + 1, e);
  tree[si] = min(tree[2 * si + 1], tree[2 * si + 2]);
}
void update(long long si, long long ss, long long se, long long us,
            long long ue, long long diff) {
  if (us > ue) return;
  if (lazy[si] != 0) {
    tree[si] += lazy[si];
    if (ss != se) {
      lazy[si * 2 + 1] += lazy[si];
      lazy[si * 2 + 2] += lazy[si];
    }
    lazy[si] = 0;
  }
  if (ss > se || ss > ue || se < us) return;
  if (ss >= us && se <= ue) {
    tree[si] += diff;
    if (ss != se) {
      lazy[si * 2 + 1] += diff;
      lazy[si * 2 + 2] += diff;
    }
    return;
  }
  long long mid = (ss + se) / 2;
  update(si * 2 + 1, ss, mid, us, ue, diff);
  update(si * 2 + 2, mid + 1, se, us, ue, diff);
  tree[si] = min(tree[si * 2 + 1], tree[si * 2 + 2]);
}
long long query(long long si, long long ss, long long se, long long qs,
                long long qe) {
  if (lazy[si] != 0) {
    tree[si] += lazy[si];
    if (ss != se) {
      lazy[si * 2 + 1] += lazy[si];
      lazy[si * 2 + 2] += lazy[si];
    }
    lazy[si] = 0;
  }
  if (ss > se || ss > qe || se < qs) return 1e18;
  if (ss >= qs && se <= qe) return tree[si];
  long long mid = (ss + se) / 2;
  return min(query(2 * si + 1, ss, mid, qs, qe),
             query(2 * si + 2, mid + 1, se, qs, qe));
}
void dfs(long long r, long long dis) {
  temp++;
  for (long long i = 0; i < adj[r].size(); i++) {
    long long c = adj[r][i].first;
    long long w = adj[r][i].second;
    dfs(c, dis + w);
  }
  idx[r] = temp - 1;
  if (adj[r].size() == 0) arr[r] = dis;
}
void solve(long long r) {
  for (long long i = 0; i < que[r].size(); i++) {
    long long j = que[r][i].first;
    long long l = que[r][i].second.first;
    long long r1 = que[r][i].second.second;
    res[j] = query(0, 0, n - 1, l, r1);
  }
  for (long long i = 0; i < adj[r].size(); i++) {
    long long c = adj[r][i].first;
    long long w = adj[r][i].second;
    update(0, 0, n - 1, c, idx[c], -w);
    update(0, 0, n - 1, 0, c - 1, w);
    update(0, 0, n - 1, idx[c] + 1, n - 1, w);
    solve(c);
    update(0, 0, n - 1, c, idx[c], w);
    update(0, 0, n - 1, 0, c - 1, -w);
    update(0, 0, n - 1, idx[c] + 1, n - 1, -w);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long q;
  cin >> n >> q;
  adj.resize(n);
  que.resize(n);
  idx.resize(n);
  for (long long i = 1; i < n; i++) {
    long long p, w;
    cin >> p >> w;
    p--;
    adj[p].push_back(make_pair(i, w));
  }
  for (long long i = 0; i < q; i++) {
    long long v, l, r;
    cin >> v >> l >> r;
    v--;
    l--;
    r--;
    que[v].push_back(make_pair(i, make_pair(l, r)));
  }
  arr.resize(n, 1e18);
  dfs(0, 0);
  tree.resize(4 * n, 0);
  lazy.resize(4 * n, 0);
  constructST(0, 0, n - 1);
  res.resize(q);
  solve(0);
  for (long long i = 0; i < q; i++) {
    cout << res[i] << '\n';
  }
  return 0;
}
