#include <bits/stdc++.h>
using namespace std;
template <typename T>
void maxtt(T& t1, T t2) {
  t1 = max(t1, t2);
}
template <typename T>
void mintt(T& t1, T t2) {
  t1 = min(t1, t2);
}
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "URDL";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int& x, int y, int mod = 1000000007) {
  assert(y >= 0);
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et(int x = -1) {
  printf("%d\n", x);
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 1000000007) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }
int p[500135], w[500135];
vector<int> mp[500135], lf;
long long d[500135];
void dfs(int x) {
  d[x] = d[p[x]] + w[x];
  for (int c : mp[x]) {
    dfs(c);
  }
  if (mp[x].size() == 0) lf.push_back(x);
}
long long T[500135 * 4], lz[500135 * 4];
void Up(int rt, int l, int r) { T[rt] = min(T[(rt << 1)], T[(rt << 1 | 1)]); }
void Down(int rt, int l, int r) {
  if (lz[rt] != 0) {
    T[(rt << 1)] += lz[rt];
    lz[(rt << 1)] += lz[rt];
    T[(rt << 1 | 1)] += lz[rt];
    lz[(rt << 1 | 1)] += lz[rt];
    lz[rt] = 0;
  }
}
void upt(int rt, int l, int r, int L, int R, int val) {
  if (R <= L) return;
  if (R <= l || r <= L) return;
  if (L <= l && r <= R) {
    T[rt] += val;
    lz[rt] += val;
    return;
  }
  Down(rt, l, r);
  int mid = (l + r) / 2;
  upt((rt << 1), l, mid, L, R, val);
  upt((rt << 1 | 1), mid, r, L, R, val);
  Up(rt, l, r);
}
long long qy(int rt, int l, int r, int L, int R) {
  if (R <= l || r <= L) return (1LL << 60);
  if (L <= l && r <= R) {
    return T[rt];
  }
  Down(rt, l, r);
  int mid = (l + r) / 2;
  return min(qy((rt << 1), l, mid, L, R), qy((rt << 1 | 1), mid, r, L, R));
}
void build(int rt, int l, int r) {
  if (l + 1 == r) {
    T[rt] = d[lf[r - 1]];
    return;
  }
  int mid = (l + r) / 2;
  build((rt << 1), l, mid);
  build((rt << 1 | 1), mid, r);
  Up(rt, l, r);
}
int id[500135], N, dpl[500135], dpr[500135];
void dfs2(int x) {
  if (mp[x].size() == 0) {
    dpl[x] = dpr[x] = id[x];
    return;
  }
  dpl[x] = (1 << 30);
  for (int c : mp[x]) {
    dfs2(c);
    mintt(dpl[x], dpl[c]);
    maxtt(dpr[x], dpr[c]);
  }
}
vector<int> qs[500135];
int qv[500135], ql[500135], qr[500135], tol[500135], tor[500135];
long long ans[500135];
void cal(int x) {
  for (int c : qs[x]) {
    ans[c] = qy(1, 0, N, id[tor[ql[c]]] - 1, id[tol[qr[c]]]);
  }
  for (int c : mp[x]) {
    upt(1, 0, N, dpl[c] - 1, dpr[c], -w[c]);
    upt(1, 0, N, 0, dpl[c] - 1, w[c]);
    upt(1, 0, N, dpr[c], N, w[c]);
    cal(c);
    upt(1, 0, N, dpl[c] - 1, dpr[c], w[c]);
    upt(1, 0, N, 0, dpl[c] - 1, -w[c]);
    upt(1, 0, N, dpr[c], N, -w[c]);
  }
}
void fmain(int tid) {
  scanf("%d%d", &n, &m);
  for (int i = 2; i <= n; i++) {
    scanf("%d%d", p + i, w + i);
    mp[p[i]].push_back(i);
  }
  dfs(1);
  sort(lf.begin(), lf.end());
  N = lf.size();
  for (int(j) = 0; (j) < (int)(N); (j)++) id[lf[j]] = j + 1;
  build(1, 0, N);
  dfs2(1);
  for (int(i) = 1; (i) <= (int)(m); (i)++) {
    scanf("%d%d%d", qv + i, ql + i, qr + i);
    qs[qv[i]].push_back(i);
  }
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    tol[i] = tol[i - 1];
    if (id[i]) tol[i] = i;
  }
  for (int i = n; i; i--) {
    tor[i] = tor[i + 1];
    if (id[i]) tor[i] = i;
  }
  cal(1);
  for (int(i) = 1; (i) <= (int)(m); (i)++) printf("%lld\n", ans[i]);
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
