#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;
const long long inf = 1e17;
vector<pair<int, long long> > G[N];
int n, q, mnc[N], mxc[N], dfn[N], dfscnt;
long long dep[N], val[N], ans[N];
bool islf[N];
void dfs(int u, int fa) {
  dfn[u] = ++dfscnt;
  islf[u] = 1;
  mnc[u] = mxc[u] = -1;
  vector<pair<int, long long> >::iterator it;
  for (it = G[u].begin(); it != G[u].end(); ++it) {
    int v = (*it).first;
    if (v == fa) continue;
    islf[u] = 0;
    dep[v] = dep[u] + (*it).second;
    dfs(v, u);
    if (mnc[u] == -1 || mnc[u] > mnc[v]) mnc[u] = mnc[v];
    if (mxc[u] == -1 || mxc[u] < mxc[v]) mxc[u] = mxc[v];
  }
  if (islf[u]) {
    mnc[u] = dfn[u];
    mxc[u] = dfn[u];
    val[dfn[u]] = dep[u];
  }
}
long long mmin(long long x, long long y) { return x > y ? y : x; }
long long seg[N << 2], tag[N << 2];
void pushup(int rt) { seg[rt] = mmin(seg[rt << 1], seg[rt << 1 | 1]); }
void pushdown(int rt) {
  if (tag[rt]) {
    tag[rt << 1] += tag[rt];
    tag[rt << 1 | 1] += tag[rt];
    seg[rt << 1] += tag[rt];
    seg[rt << 1 | 1] += tag[rt];
    tag[rt] = 0;
  }
}
void build(int rt, int l, int r) {
  if (l == r) {
    seg[rt] = val[l] == 0 ? (inf) : val[l];
    return;
  }
  int mid = l + r >> 1;
  build(rt << 1, l, mid);
  build(rt << 1 | 1, mid + 1, r);
  pushup(rt);
}
void motify(int rt, int l, int r, int ql, int qr, long long k) {
  if (ql <= l && r <= qr) {
    tag[rt] += k;
    seg[rt] += k;
    return;
  }
  int mid = l + r >> 1;
  pushdown(rt);
  if (mid >= ql) motify(rt << 1, l, mid, ql, qr, k);
  if (mid + 1 <= qr) motify(rt << 1 | 1, mid + 1, r, ql, qr, k);
  pushup(rt);
}
long long query(int rt, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) return seg[rt];
  pushdown(rt);
  int mid = l + r >> 1;
  long long res = inf;
  if (mid >= ql) res = mmin(res, query(rt << 1, l, mid, ql, qr));
  if (mid + 1 <= qr) res = mmin(res, query(rt << 1 | 1, mid + 1, r, ql, qr));
  pushup(rt);
  return res;
}
struct ques {
  int l, r, id;
};
vector<ques> qry[N];
void dfs1(int u, int fa) {
  vector<ques>::iterator it1;
  for (it1 = qry[u].begin(); it1 != qry[u].end(); ++it1) {
    ans[(*it1).id] = query(1, 1, n, (*it1).l, (*it1).r);
  }
  vector<pair<int, long long> >::iterator it;
  for (it = G[u].begin(); it != G[u].end(); ++it) {
    int v = (*it).first;
    if (v == fa) continue;
    motify(1, 1, n, mnc[v], mxc[v], -(*it).second);
    if (mnc[v] > 1) motify(1, 1, n, 1, mnc[v] - 1, (*it).second);
    if (mxc[v] < n) motify(1, 1, n, mxc[v] + 1, n, (*it).second);
    dfs1(v, u);
    motify(1, 1, n, mnc[v], mxc[v], (*it).second);
    if (mnc[v] > 1) motify(1, 1, n, 1, mnc[v] - 1, -(*it).second);
    if (mxc[v] < n) motify(1, 1, n, mxc[v] + 1, n, -(*it).second);
  }
}
int main() {
  scanf("%d%d", &n, &q);
  int i;
  for (i = 2; i <= (n); ++i) {
    int x;
    long long w;
    scanf("%d%I64d", &x, &w);
    G[x].push_back(make_pair(i, w));
    G[i].push_back(make_pair(x, w));
  }
  for (i = 1; i <= n; ++i) sort(G[i].begin(), G[i].end());
  for (i = 1; i <= (2e6 + 10); ++i) seg[i] = inf;
  for (i = 1; i <= q; ++i) {
    int v, l, r;
    scanf("%d%d%d", &v, &l, &r);
    qry[v].push_back((ques){l, r, i});
  }
  dfs(1, 0);
  build(1, 1, n);
  dfs1(1, 0);
  for (i = 1; i <= q; ++i) printf("%I64d\n", ans[i]);
}
