#include <bits/stdc++.h>
using namespace std;
inline int Get() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, m;
int d[500005];
struct tree {
  int l, r;
  long long mn, tag;
} tr[500005 << 2];
long long dis[500005], ed[500005];
void update(int v) { tr[v].mn = min(tr[v << 1].mn, tr[v << 1 | 1].mn); }
void Set(int v, long long f) {
  tr[v].mn += f;
  tr[v].tag += f;
}
void down(int v) {
  if (tr[v].tag) {
    Set(v << 1, tr[v].tag);
    Set(v << 1 | 1, tr[v].tag);
    tr[v].tag = 0;
  }
}
void build(int v, int l, int r) {
  tr[v].l = l, tr[v].r = r;
  if (l == r) {
    tr[v].mn = dis[l];
    return;
  }
  int mid = l + r >> 1;
  build(v << 1, l, mid), build(v << 1 | 1, mid + 1, r);
  update(v);
}
long long Ask(int v, int l, int r) {
  if (tr[v].l > r || tr[v].r < l) return 1ll << 60;
  if (l <= tr[v].l && tr[v].r <= r) return tr[v].mn;
  down(v);
  return min(Ask(v << 1, l, r), Ask(v << 1 | 1, l, r));
}
void Modify(int v, int l, int r, long long f) {
  if (tr[v].l > r || tr[v].r < l) return;
  if (l <= tr[v].l && tr[v].r <= r) {
    Set(v, f);
    return;
  }
  down(v);
  Modify(v << 1, l, r, f), Modify(v << 1 | 1, l, r, f);
  update(v);
}
struct node {
  int v, w;
};
vector<node> e[500005];
void dfs(int v) {
  ed[v] = v;
  for (int i = 0; i < e[v].size(); i++) {
    int to = e[v][i].v;
    dis[to] = dis[v] + e[v][i].w;
    dfs(to);
    ed[v] = max(ed[v], ed[to]);
  }
}
struct query {
  int l, r, id;
};
long long ans[500005];
vector<query> Q[500005];
void solve(int v) {
  for (int i = 0; i < Q[v].size(); i++) {
    int l = Q[v][i].l, r = Q[v][i].r;
    ans[Q[v][i].id] = Ask(1, l, r);
  }
  for (int i = 0; i < e[v].size(); i++) {
    int to = e[v][i].v, w = e[v][i].w;
    Modify(1, to, ed[to], -w);
    if (to > 1) Modify(1, 1, to - 1, w);
    if (ed[to] < n) Modify(1, ed[to] + 1, n, w);
    solve(to);
    Modify(1, to, ed[to], w);
    if (to > 1) Modify(1, 1, to - 1, -w);
    if (ed[to] < n) Modify(1, ed[to] + 1, n, -w);
  }
}
int main() {
  n = Get(), m = Get();
  for (int i = 2; i <= n; i++) {
    int fa = Get(), w = Get();
    e[fa].push_back((node){i, w});
    d[fa]++, d[i]++;
  }
  dfs(1);
  dis[1] = 1ll << 50;
  for (int i = 2; i <= n; i++)
    if (d[i] != 1) dis[i] = 1ll << 50;
  build(1, 1, n);
  for (int i = 1; i <= m; i++) {
    int v = Get(), l = Get(), r = Get();
    Q[v].push_back((query){l, r, i});
  }
  solve(1);
  for (int i = 1; i <= m; i++) cout << ans[i] << "\n";
  return 0;
}
