#include <bits/stdc++.h>
using namespace std;
const int maxN = 5e5 + 5;
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
int n, mx[maxN], st[maxN], fn[maxN], TIME = 0;
long long H[maxN], res[maxN];
long long seg[4 * maxN], lzy[4 * maxN];
vector<pair<int, pair<int, int> > > Q[maxN];
vector<pair<long long, long long> > G[maxN];
void build(int id = 1, int s = 0, int e = n) {
  if (e - s <= 1) {
    seg[id] = (!G[s + 1].empty() ? INF : H[s + 1]);
    return;
  }
  int md = (s + e) / 2;
  build(2 * id, s, md);
  build(2 * id + 1, md, e);
  seg[id] = min(seg[2 * id], seg[2 * id + 1]);
  return;
}
void apply(int id, int x) {
  seg[id] += x;
  lzy[id] += x;
  return;
}
void shift(int id) {
  apply(2 * id, lzy[id]);
  apply(2 * id + 1, lzy[id]);
  lzy[id] = 0;
  return;
}
void update(int l, int r, long long x, int id = 1, int s = 0, int e = n) {
  if (l <= s && e <= r) {
    apply(id, x);
    return;
  }
  if (l >= e || s >= r) return;
  shift(id);
  int md = (s + e) / 2;
  update(l, r, x, 2 * id, s, md);
  update(l, r, x, 2 * id + 1, md, e);
  seg[id] = min(seg[2 * id], seg[2 * id + 1]);
  return;
}
long long fetch(int l, int r, int id = 1, int s = 0, int e = n) {
  if (l <= s && e <= r) return seg[id];
  if (l >= e || s >= r) return INF;
  shift(id);
  int md = (s + e) / 2;
  return min(fetch(l, r, 2 * id, s, md), fetch(l, r, 2 * id + 1, md, e));
}
int DFS(int v) {
  st[v] = TIME++;
  for (pair<int, int> pp : G[v]) {
    int u, w;
    tie(u, w) = pp;
    H[u] = H[v] + w;
    mx[v] = max(mx[v], DFS(u));
  }
  fn[v] = TIME;
  mx[v] = max(mx[v], v);
  return mx[v];
}
void QUERY(int v) {
  for (auto ppp : Q[v]) {
    int i, l, r;
    pair<int, int> pp;
    tie(i, pp) = ppp;
    tie(l, r) = pp;
    res[i] = fetch(l - 1, r);
  }
  for (pair<int, int> pp : G[v]) {
    int u, w;
    tie(u, w) = pp;
    update(st[u], fn[u], -2 * w);
    update(0, n, w);
    QUERY(u);
    update(st[u], fn[u], 2 * w);
    update(0, n, -w);
  }
  return;
}
int main() {
  time_t START = clock();
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q;
  scanf("%d%d", &n, &q);
  for (int i = 1; i < n; i++) {
    int p, w;
    scanf("%d%d", &p, &w);
    G[p].push_back({i + 1, w});
  }
  DFS(1);
  build();
  for (int i = 0; i < q; i++) {
    int v, l, r;
    scanf("%d%d%d", &v, &l, &r);
    Q[v].push_back({i, {l, r}});
  }
  QUERY(1);
  for (int i = 0; i < q; i++) printf("%lld\n", res[i]);
  time_t FINISH = clock();
  cerr << "Execution time: "
       << (long double)(FINISH - START) / CLOCKS_PER_SEC * 1000.0
       << " milliseconds.\n";
  return 0;
}
