#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10;
const int maxt = (1 << 21) + 10;
int n, q, m;
vector<pair<int, long long> > g[maxn];
vector<int> leaves;
long long dis[maxn], ans[maxn];
vector<pair<pair<int, int>, int> > qs[maxn];
int rht[maxn];
void dfs(int x, long long fr) {
  rht[x] = x;
  if (!g[x].size()) {
    dis[leaves.size()] = fr;
    leaves.push_back(x);
    return;
  }
  for (int i = 0; i < g[x].size(); i++) {
    dfs(g[x][i].first, g[x][i].second + fr);
    rht[x] = max(rht[x], rht[g[x][i].first]);
  }
}
long long dat[maxt], tag[maxt];
void build(int x, int l, int r) {
  if (l == r) {
    dat[x] = dis[l];
    return;
  }
  int mid = (l + r) >> 1;
  build(x * 2, l, mid);
  build(x * 2 + 1, mid + 1, r);
  dat[x] = min(dat[x * 2], dat[x * 2 + 1]);
}
void pushdown(int x) {
  if (!tag[x]) return;
  dat[x * 2] += tag[x];
  dat[x * 2 + 1] += tag[x];
  tag[x * 2] += tag[x];
  tag[x * 2 + 1] += tag[x];
  tag[x] = 0;
}
long long query(int x, int l, int r, int tl, int tr) {
  if (l > tr || r < tl) return 0x3f3f3f3f3f3f3f3fll;
  if (tl <= l && r <= tr) return dat[x];
  pushdown(x);
  int mid = (l + r) >> 1;
  return min(query(x * 2, l, mid, tl, tr),
             query(x * 2 + 1, mid + 1, r, tl, tr));
}
void modify(int x, int l, int r, int tl, int tr, long long v) {
  if (l > tr || r < tl) return;
  if (tl <= l && r <= tr) {
    dat[x] += v;
    tag[x] += v;
    return;
  }
  pushdown(x);
  int mid = (l + r) >> 1;
  modify(x * 2, l, mid, tl, tr, v);
  modify(x * 2 + 1, mid + 1, r, tl, tr, v);
  dat[x] = min(dat[x * 2], dat[x * 2 + 1]);
}
long long offset = 0;
void solve(int x) {
  for (int i = 0; i < qs[x].size(); i++) {
    ans[qs[x][i].second] =
        query(1, 0, m - 1, qs[x][i].first.first, qs[x][i].first.second) +
        offset;
  }
  for (int i = 0; i < g[x].size(); i++) {
    int to = g[x][i].first;
    long long w = g[x][i].second;
    offset += w;
    int l = to, r = rht[to];
    l = lower_bound(leaves.begin(), leaves.end(), l) - leaves.begin();
    r = lower_bound(leaves.begin(), leaves.end(), r + 1) - leaves.begin() - 1;
    modify(1, 0, m - 1, l, r, -w * 2);
    solve(to);
    modify(1, 0, m - 1, l, r, w * 2);
    offset -= w;
  }
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; i++) {
    int p;
    long long w;
    scanf("%d%I64d", &p, &w);
    g[p].push_back(make_pair(i, w));
  }
  dfs(1, 0);
  m = leaves.size();
  for (int i = 1; i <= q; i++) {
    int v, l, r;
    scanf("%d%d%d", &v, &l, &r);
    l = lower_bound(leaves.begin(), leaves.end(), l) - leaves.begin();
    r = lower_bound(leaves.begin(), leaves.end(), r + 1) - leaves.begin() - 1;
    qs[v].push_back(make_pair(make_pair(l, r), i));
  }
  build(1, 0, m - 1);
  solve(1);
  for (int i = 1; i <= q; i++) {
    printf("%I64d\n", ans[i]);
  }
  return 0;
}
