#include <bits/stdc++.h>
using namespace std;
struct query {
  int l, r, id;
};
vector<pair<int, long long>> e[500000];
vector<query> Q[500000];
long long R[500000];
const int TSIZE = (1 << 20);
const int TSTART = (TSIZE / 2) - 1;
long long T[TSIZE];
long long M[TSIZE];
int tl, tr;
void add(int x, int l, int r, long long d) {
  int long long = max(tl, l);
  int rr = min(tr, r);
  if (long long == l && rr == r) {
    T[x] += d;
  } else if (long long < rr) {
    int m = (l + r) >> 1;
    add(x * 2 + 1, l, m, d + T[x]);
    add(x * 2 + 2, m, r, d + T[x]);
    long long v1 = M[x * 2 + 1];
    if (v1 != 1LL << 62) v1 += T[x * 2 + 1];
    long long v2 = M[x * 2 + 2];
    if (v2 != 1LL << 62) v2 += T[x * 2 + 2];
    M[x] = min(v1, v2);
  }
}
void add(int l, int r, long long d) {
  tl = l;
  tr = r + 1;
  add(0, 0, TSIZE / 2, d);
}
long long get(int x, int l, int r) {
  long long res;
  int long long = max(tl, l);
  int rr = min(tr, r);
  if (long long == l && rr == r) {
    res = M[x];
    if (res != 1LL << 62) res += T[x];
    return res;
  } else if (long long >= rr) {
    return 1LL << 62;
  } else {
    int m = (l + r) >> 1;
    res = min(get(x * 2 + 1, l, m), get(x * 2 + 2, m, r));
    if (res != 1LL << 62) res += T[x];
    return res;
  }
}
long long get(int l, int r) {
  tl = l;
  tr = r + 1;
  long long rr = get(0, 0, TSIZE / 2);
  return rr;
}
int im[500000];
int iM[500000];
void dfs(int x) {
  im[x] = x;
  iM[x] = x;
  vector<pair<int, long long>> &ee = e[x];
  for (int i = 0; i < ee.size(); ++i) {
    int v = ee[i].first;
    dfs(v);
    im[x] = min(im[x], im[v]);
    iM[x] = max(iM[x], iM[v]);
  }
}
void dfs1(int x) {
  vector<query> &q = Q[x];
  for (int i = 0; i < q.size(); ++i) {
    R[q[i].id] = get(q[i].l, q[i].r);
  }
  vector<pair<int, long long>> &ee = e[x];
  for (int i = 0; i < ee.size(); ++i) {
    int v = ee[i].first;
    long long d = ee[i].second;
    add(0, im[v] - 1, d);
    add(iM[v] + 1, 500000 - 1, d);
    add(im[v], iM[v], -d);
    dfs1(v);
    add(0, im[v] - 1, -d);
    add(iM[v] + 1, 500000 - 1, -d);
    add(im[v], iM[v], d);
  }
}
void build(int n) {
  for (int x = 0; x < n; ++x) {
    if (im[x] == x && iM[x] == x) {
      M[TSTART + x] = T[TSTART + x];
    } else {
      M[TSTART + x] = 1LL << 62;
    }
    T[TSTART + x] = 0;
  }
  for (int x = n + TSTART; x < TSIZE; ++x) {
    M[x] = 1LL << 62;
  }
  for (int x = TSTART - 1; x >= 0; --x) {
    M[x] = min(M[x * 2 + 1], M[x * 2 + 2]);
  }
}
void solve() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 1; i < n; ++i) {
    int x, w;
    scanf("%d%d", &x, &w);
    T[TSTART + i] = T[TSTART + x - 1] + w;
    e[x - 1].push_back(pair<int, long long>(i, w));
  }
  for (int i = 0; i < q; ++i) {
    int v;
    query q;
    scanf("%d%d%d", &v, &q.l, &q.r);
    --v, --q.l, --q.r;
    q.id = i;
    Q[v].push_back(q);
  }
  dfs(0);
  build(n);
  dfs1(0);
  for (int i = 0; i < q; ++i) {
    printf("%I64d\n", R[i]);
  }
}
int main() {
  solve();
  return 0;
}
