#include <bits/stdc++.h>
using namespace std;
const int MAXS = 1 << 21;
const int MAXN = 500005;
const int MAXP = 21;
vector<pair<int, int>> E[MAXN];
int H[MAXN], nn, fir[MAXN], las[MAXN];
int table[MAXP][MAXN * 2];
int pre[MAXN], post[MAXN], siz[MAXN], pp;
vector<pair<int, int>> ch[MAXN];
long long sum[MAXS], prop[MAXS], WH[MAXN];
void go(int x, int p = -1) {
  fir[x] = nn;
  table[0][nn++] = x;
  siz[x] = 1;
  pre[x] = ++pp;
  for (auto e : E[x]) {
    int y = e.first, w = e.second;
    if (y == p) continue;
    WH[y] = WH[x] + w;
    H[y] = H[x] + 1;
    go(y, x);
    siz[x] += siz[y];
    table[0][nn++] = x;
    ch[x].push_back({las[y], y});
  }
  las[x] = nn - 1;
  post[x] = pp;
}
void update(int sn, int s, int e, int qs, int qe, long long x) {
  if (qs <= s && e <= qe) {
    sum[sn] += x;
    prop[sn] += x;
    return;
  }
  int m = (s + e) / 2, lsn = sn * 2, rsn = sn * 2 + 1;
  if (prop[sn]) {
    update(lsn, s, m, s, m, prop[sn]);
    update(rsn, m + 1, e, m + 1, e, prop[sn]);
    prop[sn] = 0;
  }
  if (qs <= m) update(lsn, s, m, qs, qe, x);
  if (qe > m) update(rsn, m + 1, e, qs, qe, x);
  sum[sn] = min(sum[lsn], sum[rsn]);
}
long long query(int sn, int s, int e, int qs, int qe) {
  if (qs <= s && e <= qe) {
    return sum[sn];
  }
  int m = (s + e) / 2, lsn = sn * 2, rsn = sn * 2 + 1;
  if (prop[sn]) {
    update(lsn, s, m, s, m, prop[sn]);
    update(rsn, m + 1, e, m + 1, e, prop[sn]);
    prop[sn] = 0;
  }
  long long ret = 1LL << 60;
  if (qs <= m) ret = min(ret, query(lsn, s, m, qs, qe));
  if (qe > m) ret = min(ret, query(rsn, m + 1, e, qs, qe));
  return ret;
}
int L[MAXN], R[MAXN];
long long ans[MAXN];
vector<int> queries[MAXN];
void solve(int x) {
  for (int q : queries[x]) {
    ans[q] = WH[x] + query(1, 1, pp, L[q], R[q]);
  }
  for (auto e : E[x]) {
    int y = e.first, w = e.second;
    update(1, 1, pp, pre[y], post[y], -2 * w);
    solve(y);
    update(1, 1, pp, pre[y], post[y], 2 * w);
  }
}
int main() {
  int N, Q;
  scanf("%d%d", &N, &Q);
  for (int i = 2; i <= N; ++i) {
    int a, w;
    scanf("%d%d", &a, &w);
    int b = i;
    E[a].push_back({b, w});
  }
  go(1);
  assert(pp == N);
  for (int p = 1; p < MAXP; ++p)
    for (int i = 0; i < nn; ++i)
      if (i + (1 << p) - 1 < nn) {
        int x = table[p - 1][i];
        int y = table[p - 1][i + (1 << (p - 1))];
        table[p][i] = H[x] < H[y] ? x : y;
      }
  for (int i = 1; i <= N; ++i) {
    if (E[i].size() == 0) {
      assert(pre[i] == post[i]);
      update(1, 1, pp, pre[i], post[i], WH[i]);
    } else
      update(1, 1, pp, pre[i], pre[i], 1LL << 60);
  }
  for (int i = 1; i <= Q; ++i) {
    int v, l, r;
    scanf("%d%d%d", &v, &l, &r);
    queries[v].push_back(i);
    L[i] = l;
    R[i] = r;
  }
  solve(1);
  for (int i = 1; i <= Q; ++i) printf("%lld\n", ans[i]);
}
