#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
const long long inf = 1LL << 60;
int n, qn, a[N], dfsc = 0, id[N], siz[N];
long long dis[N], ans[N];
bool isLeaf[N];
struct Edge {
  int to;
  long long val;
  inline Edge(int To = 0, long long Val = 0LL) { to = To, val = Val; }
  friend bool operator<(const Edge x, const Edge y) { return x.to < y.to; }
};
vector<Edge> G[N];
struct Querys {
  int l, r, id;
  inline Querys(int L = 0, int R = 0, int Id = 0) { l = L, r = R, id = Id; }
};
vector<Querys> q[N];
template <typename T>
inline void read(T &X) {
  X = 0;
  char ch = 0;
  T op = 1;
  for (; ch > '9' || ch < '0'; ch = getchar())
    if (ch == '-') op = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    X = (X << 3) + (X << 1) + ch - 48;
  X *= op;
}
template <typename T>
inline void chkMin(T &x, T y) {
  if (y < x) x = y;
}
namespace SegT {
long long s[N << 2], tag[N << 2];
inline void up(int p) { s[p] = min(s[p << 1], s[p << 1 | 1]); }
inline void down(int p) {
  if (!tag[p]) return;
  tag[p << 1] += tag[p], s[p << 1] += tag[p];
  tag[p << 1 | 1] += tag[p], s[p << 1 | 1] += tag[p];
  tag[p] = 0;
}
void build(int p, int l, int r) {
  s[p] = inf, tag[p] = 0;
  if (l == r) {
    if (isLeaf[a[l]]) s[p] = dis[a[l]];
    return;
  }
  build(p << 1, l, ((l + r) >> 1));
  build(p << 1 | 1, ((l + r) >> 1) + 1, r);
  up(p);
}
void modify(int p, int l, int r, int x, int y, long long v) {
  if (x > y) return;
  if (x <= l && y >= r) {
    s[p] += v;
    tag[p] += v;
    return;
  }
  down(p);
  if (x <= ((l + r) >> 1)) modify(p << 1, l, ((l + r) >> 1), x, y, v);
  if (y > ((l + r) >> 1)) modify(p << 1 | 1, ((l + r) >> 1) + 1, r, x, y, v);
  up(p);
}
long long query(int p, int l, int r, int x, int y) {
  if (x > y) return inf;
  if (x <= l && y >= r) return s[p];
  down(p);
  long long res = inf;
  if (x <= ((l + r) >> 1)) chkMin(res, query(p << 1, l, ((l + r) >> 1), x, y));
  if (y > ((l + r) >> 1))
    chkMin(res, query(p << 1 | 1, ((l + r) >> 1) + 1, r, x, y));
  return res;
}
}  // namespace SegT
using namespace SegT;
void dfs(int x, int fat, long long nowDis) {
  a[id[x] = ++dfsc] = x, dis[x] = nowDis, isLeaf[x] = 1, siz[x] = 1;
  for (auto it : G[x]) {
    int y = it.to;
    if (y == fat) continue;
    isLeaf[x] = 0;
    dfs(y, x, nowDis + it.val);
    siz[x] += siz[y];
  }
}
void solve(int x, int fat) {
  for (auto it : q[x]) ans[it.id] = query(1, 1, n, it.l, it.r);
  for (auto it : G[x]) {
    int y = it.to;
    if (y == fat) continue;
    modify(1, 1, n, id[y], id[y] + siz[y] - 1, -it.val);
    modify(1, 1, n, 1, id[y] - 1, it.val);
    modify(1, 1, n, id[y] + siz[y], n, it.val);
    solve(y, x);
    modify(1, 1, n, id[y], id[y] + siz[y] - 1, it.val);
    modify(1, 1, n, 1, id[y] - 1, -it.val);
    modify(1, 1, n, id[y] + siz[y], n, -it.val);
  }
}
int main() {
  read(n), read(qn);
  for (int i = 2; i <= n; i++) {
    int fat;
    long long v;
    read(fat), read(v);
    G[i].push_back(Edge(fat, v)), G[fat].push_back(Edge(i, v));
  }
  for (int i = 1; i <= n; i++) sort(G[i].begin(), G[i].end());
  dfs(1, 0, 0LL);
  build(1, 1, n);
  for (int x, l, r, i = 1; i <= qn; i++) {
    read(x), read(l), read(r);
    q[x].push_back(Querys(l, r, i));
  }
  solve(1, 0);
  for (int i = 1; i <= qn; i++) printf("%I64d\n", ans[i]);
  return 0;
}
