#include <bits/stdc++.h>
using namespace std;
const int P = 1050000;
const int N = 500010;
int u;
long long st[P], tag[P], tg;
void pushup(int x) { st[x] = min(st[x << 1], st[x << 1 | 1]) + tag[x]; }
void Add(int s, int t, long long v) {
  int ss = u + s, tt = u + t;
  for (s += u - 1, t += u + 1; s ^ t ^ 1;
       pushup(ss >>= 1), pushup(tt >>= 1), s >>= 1, t >>= 1) {
    if (~s & 1) st[s ^ 1] += v, tag[s ^ 1] += v;
    if (t & 1) st[t ^ 1] += v, tag[t ^ 1] += v;
  }
  for (s >>= 1, t >>= 1; s != t; s >>= 1, t >>= 1) pushup(s), pushup(t);
  for (; s; s >>= 1) pushup(s);
}
long long ask(int s, int t) {
  long long retl = LLONG_MAX >> 1, retr = retl;
  int ss = u + s, tt = u + t;
  for (s += u - 1, t += u + 1; s ^ t ^ 1;
       retl += tag[ss >>= 1], retr += tag[tt >>= 1], s >>= 1, t >>= 1) {
    if (~s & 1) retl = min(retl, st[s ^ 1]);
    if (t & 1) retr = min(retr, st[t ^ 1]);
  }
  for (s >>= 1, t >>= 1; s != t; s >>= 1, t >>= 1)
    retl += tag[s], retr += tag[t];
  retl = min(retl, retr);
  for (; s; s >>= 1) retl += tag[s];
  return retl;
}
int clk, dfn[N], en[N];
vector<pair<int, int> > g[N];
vector<int> a[N];
long long ans[N];
int la[N], ra[N];
void dfs(int x, long long dep) {
  dfn[x] = ++clk;
  if (!g[x].size()) {
    st[u + clk] = dep;
    en[x] = clk;
    return;
  }
  st[u + clk] = LLONG_MAX >> 1;
  for (auto j : g[x]) dfs(j.first, dep + j.second);
  en[x] = clk;
}
void dfs2(int x) {
  for (auto j : a[x]) ans[j] = tg + ask(la[j], ra[j]);
  for (auto j : g[x]) {
    tg += j.second;
    Add(dfn[j.first], en[j.first], -j.second * 2);
    dfs2(j.first);
    Add(dfn[j.first], en[j.first], j.second * 2);
    tg -= j.second;
  }
}
int n, q;
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    g[x].push_back(make_pair(i, y));
  }
  for (u = 1; u < n; u <<= 1)
    ;
  --u;
  dfs(1, 0);
  for (int i = u + n + 1; i <= u + u + 1; ++i) st[i] = LLONG_MAX >> 1;
  for (int i = u; i; --i) st[i] = min(st[i << 1], st[i << 1 | 1]);
  for (int i = 1; i <= q; ++i) {
    int x;
    scanf("%d%d%d", &x, &la[i], &ra[i]);
    a[x].push_back(i);
  }
  dfs2(1);
  for (int i = 1; i <= q; ++i) cout << ans[i] << '\n';
}
