#include <bits/stdc++.h>
using namespace std;
const int N = 2000005;
struct Q {
  int l, r, id;
};
int n, m, e[N], ec, fi[N], nx[N], sz[N];
long long val[N], dis[N], d[N], ans[N];
vector<Q> q[N];
void adde(int u, int v, long long w) {
  e[++ec] = v;
  dis[ec] = w;
  nx[ec] = fi[u];
  fi[u] = ec;
}
long long mn[N], f[N];
void down(int o) {
  mn[(o << 1)] += f[o];
  mn[(o << 1 | 1)] += f[o];
  f[(o << 1)] += f[o];
  f[(o << 1 | 1)] += f[o];
  f[o] = 0;
}
void build(int o, int L, int R) {
  if (L == R) {
    mn[o] = val[L];
    return;
  }
  build((o << 1), L, ((L + R) >> 1));
  build((o << 1 | 1), ((L + R) >> 1) + 1, R);
  mn[o] = min(mn[(o << 1)], mn[(o << 1 | 1)]);
}
void ins(int o, int L, int R, int st, int ed, long long x) {
  if (st <= L && R <= ed) {
    f[o] += x;
    mn[o] += x;
    return;
  }
  down(o);
  if (st <= ((L + R) >> 1)) ins((o << 1), L, ((L + R) >> 1), st, ed, x);
  if (((L + R) >> 1) < ed) ins((o << 1 | 1), ((L + R) >> 1) + 1, R, st, ed, x);
  mn[o] = min(mn[(o << 1)], mn[(o << 1 | 1)]);
}
long long ask(int o, int L, int R, int st, int ed) {
  if (st <= L && R <= ed) return mn[o];
  down(o);
  long long h = 1e17;
  if (st <= ((L + R) >> 1))
    h = min(h, ask((o << 1), L, ((L + R) >> 1), st, ed));
  if (((L + R) >> 1) < ed)
    h = min(h, ask((o << 1 | 1), ((L + R) >> 1) + 1, R, st, ed));
  return h;
}
void dfs1(int u) {
  sz[u] = 1;
  if (!fi[u]) val[u] = d[u];
  for (int i = fi[u]; i; i = nx[i]) {
    int v = e[i], w = dis[i];
    d[v] = d[u] + w;
    dfs1(v);
    sz[u] += sz[v];
  }
}
void dfs2(int u) {
  for (int i = 0; i < q[u].size(); ++i)
    ans[q[u][i].id] = ask(1, 1, n, q[u][i].l, q[u][i].r);
  for (int i = fi[u]; i; i = nx[i]) {
    int v = e[i], w = dis[i];
    ins(1, 1, n, 1, n, w);
    ins(1, 1, n, v, v + sz[v] - 1, -2 * w);
    dfs2(v);
    ins(1, 1, n, 1, n, -w);
    ins(1, 1, n, v, v + sz[v] - 1, 2 * w);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 2; i <= n; ++i) {
    int fa, w;
    scanf("%d%d", &fa, &w);
    adde(fa, i, w);
  }
  for (int i = 1; i <= m; ++i) {
    int u, l, r;
    scanf("%d%d%d", &u, &l, &r);
    q[u].push_back((Q){l, r, i});
  }
  for (int i = 1; i <= n; ++i) val[i] = 1e17;
  dfs1(1);
  build(1, 1, n);
  dfs2(1);
  for (int i = 1; i <= m; ++i) printf("%lld\n", ans[i]);
  return 0;
}
