#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10;
const int maxq = 5e5 + 10;
const long long INF = 1e18;
int n, q;
int p[maxn], w[maxn], L[maxn], R[maxn];
long long dis[maxn], ans[maxq], Add[maxn << 2], Min[maxn << 2];
bool isleaf[maxn];
vector<pair<int, int> > E[maxn];
struct Ask {
  int l, r, id;
  Ask() = default;
  Ask(int _l, int _r, int _id) : l(_l), r(_r), id(_id) {}
};
vector<Ask> ask[maxq];
void dfs1(int x) {
  L[x] = R[x] = x;
  if (E[x].empty())
    isleaf[x] = 1;
  else
    for (auto e : E[x]) {
      int v = e.first, val = e.second;
      dis[v] = dis[x] + val;
      dfs1(v);
      R[x] = max(R[x], R[v]);
    }
}
void pushup(int rt) { Min[rt] = min(Min[(rt << 1)], Min[(rt << 1 | 1)]); }
void tag(int rt, long long val) {
  if (Min[rt] != INF) Add[rt] += val, Min[rt] += val;
}
void pushdown(int rt) {
  if (Add[rt]) {
    tag((rt << 1), Add[rt]);
    tag((rt << 1 | 1), Add[rt]);
    Add[rt] = 0;
  }
}
void build(int rt, int l, int r) {
  if (l == r) {
    Min[rt] = isleaf[l] ? dis[l] : INF;
    return;
  }
  int mid = l + r >> 1;
  build((rt << 1), l, mid);
  build((rt << 1 | 1), mid + 1, r);
  pushup(rt);
}
void modify(int rt, int l, int r, int a, int b, int val) {
  if (a <= l && r <= b) {
    tag(rt, val);
    return;
  }
  pushdown(rt);
  int mid = l + r >> 1;
  if (a <= mid) modify((rt << 1), l, mid, a, b, val);
  if (b > mid) modify((rt << 1 | 1), mid + 1, r, a, b, val);
  pushup(rt);
}
long long query(int rt, int l, int r, int a, int b) {
  if (a <= l && r <= b) return Min[rt];
  pushdown(rt);
  int mid = l + r >> 1;
  long long ret = INF;
  if (a <= mid) ret = min(ret, query((rt << 1), l, mid, a, b));
  if (b > mid) ret = min(ret, query((rt << 1 | 1), mid + 1, r, a, b));
  return ret;
}
void dfs2(int x) {
  for (auto q : ask[x]) ans[q.id] = query(1, 1, n, q.l, q.r);
  for (auto e : E[x]) {
    int v = e.first, val = e.second;
    modify(1, 1, n, L[v], R[v], -val);
    if (L[v] > 1) modify(1, 1, n, 1, L[v] - 1, val);
    if (R[v] < n) modify(1, 1, n, R[v] + 1, n, val);
    dfs2(v);
    modify(1, 1, n, L[v], R[v], val);
    if (L[v] > 1) modify(1, 1, n, 1, L[v] - 1, -val);
    if (R[v] < n) modify(1, 1, n, R[v] + 1, n, -val);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> q;
  for (int i = 2; i <= n; ++i) {
    cin >> p[i] >> w[i];
    E[p[i]].push_back(make_pair(i, w[i]));
  }
  for (int i = 1; i <= q; ++i) {
    int v, l, r;
    cin >> v >> l >> r;
    ask[v].emplace_back(l, r, i);
  }
  dfs1(1);
  build(1, 1, n);
  dfs2(1);
  for (int i = 1; i <= q; ++i) cout << ans[i] << endl;
  return 0;
}
