#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int _inf = 0xc0c0c0c0;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long _INF = 0xc0c0c0c0c0c0c0c0;
const long long mod = (int)1e9 + 7;
const int N = 5e5 + 100;
vector<pair<int, int>> vc[N];
int in[N], out[N], tot;
long long a[N];
int n, q;
void dfs(int u, long long ct) {
  in[u] = ++tot;
  if (vc[u].size())
    a[tot] = INF;
  else
    a[tot] = ct;
  for (pair<int, int> p : vc[u]) {
    dfs(p.first, ct + p.second);
  }
  out[u] = tot;
}
long long Mn[N << 2], lz[N << 2];
void PushUp(int rt) { Mn[rt] = min(Mn[rt << 1], Mn[rt << 1 | 1]); }
void PushDown(int rt) {
  if (lz[rt]) {
    lz[rt << 1] += lz[rt];
    lz[rt << 1 | 1] += lz[rt];
    Mn[rt << 1] += lz[rt];
    Mn[rt << 1 | 1] += lz[rt];
    lz[rt] = 0;
  }
  return;
}
void Build(int l, int r, int rt) {
  if (l == r) {
    Mn[rt] = a[l];
    return;
  }
  int m = l + r >> 1;
  Build(l, m, rt << 1);
  Build(m + 1, r, rt << 1 | 1);
  PushUp(rt);
  return;
}
void Updata(int L, int R, long long C, int l, int r, int rt) {
  if (L <= l && r <= R) {
    lz[rt] += C;
    Mn[rt] += C;
    return;
  }
  PushDown(rt);
  int m = l + r >> 1;
  if (L <= m) Updata(L, R, C, l, m, rt << 1);
  if (m < R) Updata(L, R, C, m + 1, r, rt << 1 | 1);
  PushUp(rt);
  return;
}
long long Query(int L, int R, int l, int r, int rt) {
  if (L <= l && r <= R) {
    return Mn[rt];
  }
  PushDown(rt);
  int m = l + r >> 1;
  long long ret = INF;
  if (L <= m) ret = Query(L, R, l, m, rt << 1);
  if (m < R) ret = min(ret, Query(L, R, m + 1, r, rt << 1 | 1));
  return ret;
}
vector<pair<pair<int, int>, int>> Q[N];
long long ans[N];
void Dfs(int u, int ct) {
  Updata(1, n, ct, 1, n, 1);
  Updata(in[u], out[u], -2 * ct, 1, n, 1);
  for (auto x : Q[u]) {
    ans[x.second] = Query(x.first.first, x.first.second, 1, n, 1);
  }
  for (pair<int, int> x : vc[u]) {
    Dfs(x.first, x.second);
  }
  Updata(1, n, -ct, 1, n, 1);
  Updata(in[u], out[u], 2 * ct, 1, n, 1);
  return;
}
void Ac() {
  for (int i = 2, v, w; i <= n; ++i) {
    scanf("%d%d", &v, &w);
    vc[v].push_back({i, w});
  }
  dfs(1, 0);
  Build(1, n, 1);
  for (int i = 1, u, l, r; i <= q; ++i) {
    scanf("%d%d%d", &u, &l, &r);
    Q[u].push_back(make_pair(make_pair(l, r), i));
  }
  Dfs(1, 0);
  for (int i = 1; i <= q; ++i) cout << ans[i] << endl;
}
int main() {
  while (~scanf("%d%d", &n, &q)) {
    Ac();
  }
  return 0;
}
