#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x7f7f7f7f7f7f;
const long long mo = 1e9 + 7;
template <typename _T>
void read(_T &x) {
  _T f = 1;
  x = 0;
  char s = getchar();
  while (s > '9' || s < '0') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = (x << 3) + (x << 1) + (s ^ 48);
    s = getchar();
  }
  x *= f;
}
template <typename _T>
_T Fabs(_T x) {
  return x < 0 ? -x : x;
}
long long n, q, ql[500005], qr[500005], ans[500005];
long long mxid[500005], dis[500005];
long long to[500005], nxt[500005], paid[500005];
long long head[500005], tot;
long long tree[500005 << 2], lzy[500005 << 2];
vector<long long> vec[500005];
void addEdge(long long u, long long v, long long w) {
  to[++tot] = v;
  paid[tot] = w;
  nxt[tot] = head[u];
  head[u] = tot;
}
void dfs1(long long u) {
  mxid[u] = u;
  for (long long i = head[u]; i; i = nxt[i]) {
    long long v = to[i], w = paid[i];
    dis[v] = dis[u] + w;
    dfs1(v);
    mxid[u] = max(mxid[u], mxid[v]);
  }
}
void pushdown(long long rt) {
  if (!lzy[rt]) return;
  tree[(rt << 1)] += lzy[rt];
  lzy[(rt << 1)] += lzy[rt];
  tree[(rt << 1 | 1)] += lzy[rt];
  lzy[(rt << 1 | 1)] += lzy[rt];
  lzy[rt] = 0;
}
void pushup(long long rt) {
  tree[rt] = min(tree[(rt << 1)], tree[(rt << 1 | 1)]);
}
void insert(long long rt, long long l, long long r, long long al, long long ar,
            long long w) {
  if (al <= l && r <= ar) return (void)(tree[rt] += w, lzy[rt] += w);
  pushdown(rt);
  long long mid = l + r >> 1;
  if (al <= mid) insert((rt << 1), l, mid, al, ar, w);
  if (ar > mid) insert((rt << 1 | 1), mid + 1, r, al, ar, w);
  pushup(rt);
}
long long query(long long rt, long long l, long long r, long long al,
                long long ar) {
  if (al <= l && r <= ar) return tree[rt];
  long long res = INF, mid = l + r >> 1;
  pushdown(rt);
  if (al <= mid) res = min(res, query((rt << 1), l, mid, al, ar));
  if (mid < ar) res = min(res, query((rt << 1 | 1), mid + 1, r, al, ar));
  return res;
}
void dfs2(long long x) {
  long long siz = vec[x].size();
  for (long long i = 0; i < siz; i++) {
    long long id = vec[x][i];
    ans[id] = query(1, 1, n, ql[id], qr[id]);
  }
  for (long long i = head[x]; i; i = nxt[i]) {
    long long v = to[i], w = paid[i];
    insert(1, 1, n, 1, n, w);
    insert(1, 1, n, v, mxid[v], -2ll * w);
    dfs2(v);
    insert(1, 1, n, 1, n, -w);
    insert(1, 1, n, v, mxid[v], 2ll * w);
  }
}
signed main() {
  read(n);
  read(q);
  for (long long i = 2; i <= n; i++) {
    long long u, w;
    read(u);
    read(w);
    addEdge(u, i, w);
  }
  dfs1(1);
  for (long long i = 1; i <= n; i++)
    insert(1, 1, n, i, i, mxid[i] == i ? dis[i] : INF);
  for (long long i = 1; i <= q; i++) {
    long long x;
    read(x);
    read(ql[i]);
    read(qr[i]);
    vec[x].push_back(i);
  }
  dfs2(1);
  for (long long i = 1; i <= q; i++) printf("%lld\n", ans[i]);
  return 0;
}
