#include <bits/stdc++.h>
using namespace std;
const long long md = 1e9 + 7;
const int xn = 5e5 + 10;
const int xm = 3e1 + 10;
const int SQ = 450;
const int sq = 1e3 + 10;
const int inf = 1e9 + 10;
const long long INF = 1e18 + 10;
long long power(long long a, long long b) {
  return (!b ? 1
             : (b & 1 ? a * power(a * a % md, b / 2) % md
                      : power(a * a % md, b / 2) % md));
}
long long zarb(long long a, long long b) { return (a * b + 10 * md) % md; }
long long jaam(long long a, long long b) { return (a + b + 10 * md) % md; }
int n, qq, p[xn], Root = 1, Right[xn], St[xn], S = 1;
long long Seg[xn * 4], Lazy[xn * 4], Dist[xn], ans[xn], Tot, W;
vector<pair<int, long long> > adj[xn];
vector<pair<pair<int, long long>, int> > Q[xn];
bool Mark[xn], Leaf[xn];
void Build(int id, int L, int R) {
  if (R - L == 1) {
    if (Leaf[L])
      Seg[id] = Dist[L];
    else
      Seg[id] = INF;
    return;
  }
  int Mid = (L + R) / 2;
  Build(id * 2, L, Mid);
  Build(id * 2 + 1, Mid, R);
  Seg[id] = min(Seg[id * 2], Seg[id * 2 + 1]);
}
void Shift(int id, int L, int R) {
  if (Lazy[id] == 0) return;
  if (Seg[id] != INF) Seg[id] += Lazy[id];
  if (R - L > 1) {
    Lazy[id * 2] += Lazy[id];
    Lazy[id * 2 + 1] += Lazy[id];
  }
  Lazy[id] = 0;
}
void Update(int id, int L, int R, int Ql, int Qr, long long Val) {
  Shift(id, L, R);
  if (Qr <= L || R <= Ql) return;
  if (Ql <= L && R <= Qr) {
    Lazy[id] += Val;
    Shift(id, L, R);
    return;
  }
  int Mid = (L + R) / 2;
  Update(id * 2, L, Mid, Ql, Qr, Val);
  Update(id * 2 + 1, Mid, R, Ql, Qr, Val);
  Seg[id] = min(Seg[id * 2], Seg[id * 2 + 1]);
}
long long Get(int id, int L, int R, int Ql, int Qr) {
  Shift(id, L, R);
  if (Qr <= L || R <= Ql) return INF;
  if (Ql <= L && R <= Qr) return Seg[id];
  int Mid = (L + R) / 2;
  return min(Get(id * 2, L, Mid, Ql, Qr), Get(id * 2 + 1, Mid, R, Ql, Qr));
}
void DFS2(int v) {
  for (pair<pair<int, long long>, int> q : Q[v])
    ans[q.second] = Get(1, 0, xn, q.first.first, q.first.second + 1) + Tot;
  for (pair<int, long long> u : adj[v]) {
    Tot += u.second;
    Update(1, 0, xn, St[u.first], Right[u.first] + 1, -2 * u.second);
    DFS2(u.first);
    Tot -= u.second;
    Update(1, 0, xn, St[u.first], Right[u.first] + 1, 2 * u.second);
  }
}
void DFS(int v) {
  St[v] = S++;
  Right[v] = St[v];
  for (pair<int, long long> u : adj[v]) {
    Dist[u.first] = Dist[v] + u.second;
    DFS(u.first);
    Right[v] = Right[u.first];
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> qq;
  for (int i = 1; i <= n; i++) Leaf[i] = true;
  for (int i = 2; i <= n; i++) {
    cin >> p[i] >> W;
    Leaf[p[i]] = false;
    adj[p[i]].push_back({i, W});
  }
  DFS(Root);
  Build(1, 0, xn);
  for (int i = 1; i <= qq; i++) {
    int v, l, r;
    cin >> v >> l >> r;
    Q[v].push_back({{l, r}, i});
  }
  DFS2(Root);
  for (int i = 1; i <= qq; i++) cout << ans[i] << '\n';
  return 0;
}
