#include <bits/stdc++.h>
using namespace std;
const int maxN = 5e5 + 9, maxV = 200 + 9, MOD = 1e9 + 7, AND = (1 << 20) - 1,
          lg = 20;
pair<int, int> rgs[maxN];
vector<int> qs[maxN];
long long ans[maxN];
int strt[maxN], ende[maxN], ct;
vector<pair<int, int> > adj[maxN];
long long T[maxN << 1], d[maxN];
int n;
void apply(int w, long long x) {
  T[w] += x;
  if (w < n) d[w] += x;
}
void pushDown(int w) {
  for (int i = lg - 1; i > 0; i--) {
    int c = w >> i;
    if (d[c] != 0) apply(c << 1, d[c]), apply(c << 1 | 1, d[c]);
    d[c] = 0;
  }
}
void pullup(int w) {
  while (w > 1) {
    w >>= 1;
    T[w] = min(T[w << 1], T[w << 1 | 1]) + d[w];
  }
}
long long query(int l, int r) {
  long long ret = LLONG_MAX / 2;
  l += n, r += n;
  pushDown(l), pushDown(r - 1);
  for (; l < r; l >>= 1, r >>= 1) {
    if (l & 1) ret = min(ret, T[l++]);
    if (r & 1) ret = min(ret, T[--r]);
  }
  return ret;
}
void update(int l, int r, long long x) {
  if (r <= l) return;
  l += n, r += n;
  int l0 = l, r0 = r;
  for (; l < r; l >>= 1, r >>= 1) {
    if (l & 1) apply(l++, x);
    if (r & 1) apply(--r, x);
  }
  pullup(l0), pullup(r0 - 1);
}
int q;
void dfs(int nd, long long acu) {
  strt[nd] = ct++;
  T[nd + n] = LLONG_MAX / 2;
  if (!adj[nd].size()) T[nd + n] = acu;
  for (pair<int, int> sn : adj[nd]) dfs(sn.second, acu + sn.first);
  ende[nd] = ct;
}
void solve(int nd) {
  for (int el : qs[nd]) ans[el] = query(rgs[el].first, rgs[el].second);
  for (pair<int, int> sn : adj[nd]) {
    update(strt[sn.second], ende[sn.second], -sn.first);
    update(0, strt[sn.second], sn.first), update(ende[sn.second], n, sn.first);
    solve(sn.second);
    update(strt[sn.second], ende[sn.second], sn.first);
    update(0, strt[sn.second], -sn.first),
        update(ende[sn.second], n, -sn.first);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> n >> q;
  for (int i = 1, par, cst; i < n; i++) {
    cin >> par >> cst;
    par--;
    adj[par].push_back(pair<int, int>(cst, i));
  }
  dfs(0, 0);
  for (int i = n - 1; i > 0; i--) T[i] = min(T[i << 1], T[i << 1 | 1]);
  for (int i = 0, nd; i < q; i++) {
    cin >> nd >> rgs[i].first >> rgs[i].second;
    rgs[i].first--;
    nd--;
    qs[nd].push_back(i);
  }
  solve(0);
  for (int i = 0; i < q; i++) cout << ans[i] << '\n';
}
