#include <bits/stdc++.h>
using namespace std;
inline long long gi() {
  long long data = 0, m = 1;
  char ch = 0;
  while ((ch != '-') && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') {
    m = 0;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    data = (data << 1) + (data << 3) + (ch ^ 48);
    ch = getchar();
  }
  return (m) ? data : -data;
}
int dfn[500005], ed[500005], seqL[500005], seqR[500005], fa[500005];
long long dis[500005], mn[500005 << 2], tag[500005 << 2], ans[500005];
int n, m, oo, Q;
vector<pair<int, int> > son[500005];
vector<int> vec[500005];
bool lev[500005];
void dfs(int u, long long ds) {
  dfn[u] = ++oo;
  dis[u] = ds;
  for (int j = 0, l = son[u].size(); j < l; j++) {
    pair<int, int> p = son[u][j];
    int v = p.first, w = p.second;
    dfs(v, ds + w);
  }
  ed[u] = oo;
  if (!son[u].size() && u != 1) lev[u] = true;
  return;
}
inline void PushUp(int o) { mn[o] = min(mn[o << 1], mn[o << 1 | 1]); }
inline void PushDown(int o) {
  if (tag[o] == 0) return;
  mn[o << 1] += tag[o];
  mn[o << 1 | 1] += tag[o];
  tag[o << 1] += tag[o];
  tag[o << 1 | 1] += tag[o];
  tag[o] = 0;
  return;
}
void Insert(int o, int l, int r, int ps, long long vl) {
  if (l == r) {
    mn[o] = vl;
    return;
  }
  int mid = (l + r) >> 1;
  ps <= mid ? Insert(o << 1, l, mid, ps, vl)
            : Insert(o << 1 | 1, mid + 1, r, ps, vl);
  PushUp(o);
}
void Update(int o, int l, int r, int ql, int qr, int v) {
  if (ql <= l && r <= qr) {
    tag[o] += v;
    mn[o] += v;
    return;
  }
  int mid = (l + r) >> 1;
  PushDown(o);
  if (ql <= mid) Update(o << 1, l, mid, ql, qr, v);
  if (qr > mid) Update(o << 1 | 1, mid + 1, r, ql, qr, v);
  PushUp(o);
}
long long Query(int o, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) return mn[o];
  int mid = (l + r) >> 1;
  PushDown(o);
  long long ret = 1e18;
  if (ql <= mid) ret = min(ret, Query(o << 1, l, mid, ql, qr));
  if (qr > mid) ret = min(ret, Query(o << 1 | 1, mid + 1, r, ql, qr));
  return ret;
}
void Check(int o, int l, int r) {
  if (l == r) {
    cout << mn[o] << " ";
    if (l == n) puts("");
    return;
  }
  int mid = (l + r) >> 1;
  PushDown(o);
  Check(o << 1, l, mid);
  Check(o << 1 | 1, mid + 1, r);
  PushUp(o);
}
void Dfs(int u) {
  for (int j = 0, l = vec[u].size(); j < l; j++) {
    int i = vec[u][j];
    ans[i] = Query(1, 1, n, seqL[i], seqR[i]);
  }
  for (int j = 0, l = son[u].size(); j < l; j++) {
    pair<int, int> p = son[u][j];
    int v = p.first, w = p.second;
    Update(1, 1, n, 1, n, w);
    Update(1, 1, n, dfn[v], ed[v], -2ll * w);
    Dfs(v);
    Update(1, 1, n, dfn[v], ed[v], 2ll * w);
    Update(1, 1, n, 1, n, -w);
  }
  return;
}
int main() {
  n = gi();
  Q = gi();
  for (int i = 2, w; i <= n; i++)
    fa[i] = gi(), w = gi(), son[fa[i]].push_back(make_pair(i, w));
  for (int i = 1, u; i <= Q; i++)
    u = gi(), seqL[i] = gi(), seqR[i] = gi(), vec[u].push_back(i);
  for (int i = 1; i <= n; i++) sort(son[i].begin(), son[i].end());
  dfs(1, 0);
  for (int u = 1; u <= n; u++)
    if (lev[u])
      Insert(1, 1, n, dfn[u], dis[u]);
    else
      Insert(1, 1, n, dfn[u], 1e18);
  Dfs(1);
  for (int i = 1; i <= Q; i++) printf("%I64d\n", ans[i]);
  return 0;
}
