#include <bits/stdc++.h>
using namespace std;
long long MAX = 100000000000000000;
long long tree[500005 * 4], lazyp[500005 * 4], lazym[500005 * 4];
struct Query {
  int l, r;
  int id;
};
long long ans[500005];
void Down(int node, int left, int right) {
  tree[left] += lazyp[node];
  tree[right] += lazyp[node];
  lazyp[left] += lazyp[node];
  lazyp[right] += lazyp[node];
  tree[left] += lazym[node];
  tree[right] += lazym[node];
  lazym[left] += lazym[node];
  lazym[right] += lazym[node];
  lazyp[node] = lazym[node] = 0;
}
void update(int node, int b, int e, int l, int r, long long v) {
  if (b > r || e < l) return;
  if (b >= l && e <= r) {
    tree[node] += v;
    if (v > 0)
      lazyp[node] += v;
    else
      lazym[node] += v;
    return;
  }
  int left = 2 * node, right = left + 1, mid = (b + e) / 2;
  Down(node, left, right);
  update(left, b, mid, l, r, v);
  update(right, mid + 1, e, l, r, v);
  tree[node] = min(tree[left], tree[right]);
}
long long query(int node, int b, int e, int l, int r) {
  if (b > r || e < l) return MAX;
  if (b >= l && e <= r) return tree[node];
  int left = 2 * node, right = left + 1, mid = (b + e) / 2;
  Down(node, left, right);
  long long p = query(left, b, mid, l, r);
  long long q = query(right, mid + 1, e, l, r);
  return min(p, q);
}
int n, q;
int ft[500005];
vector<pair<long long, long long> > vv[500005];
vector<Query> qr[500005];
int mx;
void dfs(int u, int par, long long c) {
  mx = max(mx, u);
  for (int i = 0; i < vv[u].size(); i++) {
    int v = vv[u][i].first;
    long long cc = vv[u][i].second;
    if (v == par) continue;
    dfs(v, u, c + cc);
  }
  if (mx == u) {
    update(1, 1, n, u, u, c);
  } else
    update(1, 1, n, u, u, MAX);
  ft[u] = mx;
}
void solve(int u, int par) {
  for (int i = 0; i < qr[u].size(); i++) {
    int l = qr[u][i].l;
    int r = qr[u][i].r;
    int id = qr[u][i].id;
    ans[id] = query(1, 1, n, l, r);
  }
  for (int i = 0; i < vv[u].size(); i++) {
    int v = vv[u][i].first;
    long long cc = vv[u][i].second;
    if (v == par) continue;
    update(1, 1, n, v, ft[v], -cc);
    update(1, 1, n, 1, v - 1, cc);
    if (ft[v] < n) {
      update(1, 1, n, ft[v] + 1, n, cc);
    }
    solve(v, u);
    update(1, 1, n, v, ft[v], cc);
    update(1, 1, n, 1, v - 1, -cc);
    if (ft[v] < n) update(1, 1, n, ft[v] + 1, n, -cc);
  }
}
int main() {
  scanf("%d %d", &n, &q);
  for (long long i = 2; i <= n; i++) {
    long long x, w;
    scanf("%lld %lld", &x, &w);
    vv[i].push_back(make_pair(x, w));
    vv[x].push_back(make_pair(i, w));
  }
  for (int i = 1; i <= n; i++) sort(vv[i].begin(), vv[i].end());
  dfs(1, 0, 0);
  for (int i = 1; i <= q; i++) {
    int v, l, r;
    scanf("%d %d %d", &v, &l, &r);
    Query x;
    x.id = i;
    x.l = l;
    x.r = r;
    qr[v].push_back(x);
  }
  solve(1, 0);
  for (int i = 1; i <= q; i++) printf("%lld\n", ans[i]);
}
