#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;
const int inf = 2147483647;
const long double pi = acos(-1);
const long long INF = 1ll << 60;
inline long long read() {
  long long data = 0, w = 1;
  char ch = getchar();
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') w = -1, ch = getchar();
  while (ch <= '9' && ch >= '0') data = data * 10 + ch - 48, ch = getchar();
  return data * w;
}
inline void file() {
  freopen(
      "a"
      ".in",
      "r", stdin);
  freopen(
      "a"
      ".out",
      "w", stdout);
}
int n, q;
vector<pair<int, int> > son[N];
int w[N], fw[N], o[N], L[N], R[N], cntw, cntleaf;
long long dep[N];
void dfs(int u, int ff) {
  w[u] = ++cntw;
  fw[cntw] = u;
  if (son[u].size() == 0) {
    L[u] = R[u] = ++cntleaf;
    o[cntleaf] = cntw;
    return;
  }
  vector<pair<int, int> >::iterator it;
  for (it = son[u].begin(); it != son[u].end(); it++) {
    int v = it->first;
    dep[v] = dep[u] + it->second;
    dfs(v, u);
    if (!L[u]) L[u] = L[v];
    R[u] = R[v];
  }
}
long long mn[N << 2], lz[N << 2];
inline void update(int i) { mn[i] = min(mn[(i << 1)], mn[(i << 1 | 1)]); }
inline void cover(int i, long long v) {
  mn[i] += v;
  lz[i] += v;
}
inline void pushdown(int i) {
  if (lz[i]) cover((i << 1), lz[i]), cover((i << 1 | 1), lz[i]), lz[i] = 0;
}
void build(int i, int l, int r) {
  if (l == r) {
    mn[i] = dep[fw[o[l]]];
    return;
  }
  build((i << 1), l, ((l + r) >> 1));
  build((i << 1 | 1), ((l + r) >> 1) + 1, r);
  update(i);
}
void modify(int i, int l, int r, int x, int y, int v) {
  if (x <= l && r <= y) {
    cover(i, v);
    return;
  }
  pushdown(i);
  if (x <= ((l + r) >> 1)) modify((i << 1), l, ((l + r) >> 1), x, y, v);
  if (((l + r) >> 1) < y) modify((i << 1 | 1), ((l + r) >> 1) + 1, r, x, y, v);
  update(i);
}
long long query(int i, int l, int r, int x, int y) {
  if (x <= l && r <= y) return mn[i];
  pushdown(i);
  long long s = INF;
  if (x <= ((l + r) >> 1)) s = query((i << 1), l, ((l + r) >> 1), x, y);
  if (((l + r) >> 1) < y)
    s = min(s, query((i << 1 | 1), ((l + r) >> 1) + 1, r, x, y));
  return s;
}
struct node {
  int l, r, id;
};
vector<node> qry[N];
long long ans[N];
void solve(int u, int ff) {
  vector<node>::iterator tmp;
  for (tmp = qry[u].begin(); tmp != qry[u].end(); tmp++) {
    int l = lower_bound(o + 1, o + cntleaf + 1, tmp->l) - o;
    int r = upper_bound(o + 1, o + cntleaf + 1, tmp->r) - o - 1;
    ans[tmp->id] = query(1, 1, cntleaf, l, r);
  }
  vector<pair<int, int> >::iterator it;
  for (it = son[u].begin(); it != son[u].end(); it++) {
    int v = it->first;
    cover(1, it->second);
    modify(1, 1, cntleaf, L[v], R[v], (-2) * it->second);
    solve(v, u);
    cover(1, -it->second);
    modify(1, 1, cntleaf, L[v], R[v], 2 * it->second);
  }
}
int main() {
  n = read();
  q = read();
  for (int i = 2, fa, w; i <= n; i++) {
    fa = read();
    w = read();
    son[fa].push_back(make_pair(i, w));
  }
  dfs(1, 0);
  build(1, 1, cntleaf);
  for (int i = 1, v, l, r; i <= q; i++) {
    v = read();
    l = read();
    r = read();
    qry[v].push_back((node){l, r, i});
  }
  solve(1, 0);
  for (int i = 1; i <= q; i++) printf("%I64d\n", ans[i]);
  return 0;
}
