#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T>
void read(T& x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  x *= f;
}
template <typename T, typename... Args>
void read(T& x, Args&... args) {
  read(x), read(args...);
}
template <typename T>
void write(T x) {
  if (x < 0) putchar('-'), write(-x);
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
const int maxn = 500500;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
int n, m;
struct segtree {
  ll addv[maxn * 4], minv[maxn * 4];
  inline void pushup(int o) {
    minv[o] = min(minv[(o << 1)], minv[(o << 1 | 1)]);
  }
  inline void pushdown(int o) {
    if (addv[o] == 0) return;
    minv[(o << 1)] += addv[o];
    minv[(o << 1 | 1)] += addv[o];
    addv[(o << 1)] += addv[o];
    addv[(o << 1 | 1)] += addv[o];
    addv[o] = 0;
  }
  void build(int o, int l, int r, ll* arr) {
    addv[o] = 0;
    if (l == r) {
      minv[o] = arr[l];
      return;
    }
    int mid = (l + r) >> 1;
    build((o << 1), l, mid, arr);
    build((o << 1 | 1), mid + 1, r, arr);
    pushup(o);
  }
  void modify(int o, int l, int r, int ql, int qr, ll d) {
    if (ql > qr) return;
    if (ql <= l && r <= qr) {
      addv[o] += d;
      minv[o] += d;
      return;
    }
    pushdown(o);
    int mid = (l + r) >> 1;
    if (ql <= mid) modify((o << 1), l, mid, ql, qr, d);
    if (qr > mid) modify((o << 1 | 1), mid + 1, r, ql, qr, d);
    pushup(o);
  }
  ll rmq(int o, int l, int r, int ql, int qr) {
    if (ql <= l && r <= qr) return minv[o];
    int mid = (l + r) >> 1;
    ll res = INF;
    pushdown(o);
    if (ql <= mid) res = min(res, rmq((o << 1), l, mid, ql, qr));
    if (qr > mid) res = min(res, rmq((o << 1 | 1), mid + 1, r, ql, qr));
    return res;
  }
} seg;
struct ask {
  int l, r, id;
} _tmp;
vector<int> son[maxn];
vector<ask> query[maxn];
int fa[maxn], _v, w[maxn], isleaf[maxn], siz[maxn];
ll d[maxn], ans[maxn];
void dfs1(int v) {
  siz[v] = 1;
  if (son[v].size() == 0) isleaf[v] = true;
  for (auto g : son[v]) {
    d[g] = d[v] + w[g];
    dfs1(g);
    siz[v] += siz[g];
  }
}
void dfs2(int v) {
  for (auto q : query[v]) ans[q.id] = seg.rmq(1, 1, n, q.l, q.r);
  for (auto g : son[v]) {
    seg.modify(1, 1, n, 1, g - 1, w[g]);
    seg.modify(1, 1, n, g, g + siz[g] - 1, -w[g]);
    seg.modify(1, 1, n, g + siz[g], n, w[g]);
    dfs2(g);
    seg.modify(1, 1, n, 1, g - 1, -w[g]);
    seg.modify(1, 1, n, g, g + siz[g] - 1, w[g]);
    seg.modify(1, 1, n, g + siz[g], n, -w[g]);
  }
}
signed main() {
  read(n, m);
  for (int i = 2; i <= n; ++i) {
    read(fa[i], w[i]);
    son[fa[i]].push_back(i);
  }
  for (int i = 1; i <= m; ++i) {
    read(_v, _tmp.l, _tmp.r);
    _tmp.id = i;
    query[_v].push_back(_tmp);
  }
  memset(d, 0x3f, sizeof d);
  memset(ans, -1, sizeof ans);
  d[1] = 0;
  dfs1(1);
  for (int i = 1; i <= n; ++i)
    if (!isleaf[i]) d[i] = INF;
  seg.build(1, 1, n, d);
  dfs2(1);
  for (int i = 1; i <= m; ++i) printf("%lld\n", ans[i]);
  return 0;
}
