#include <bits/stdc++.h>
using namespace std;
char _buf[1048576], *_is = _buf, *_it = _buf;
inline char rdc() {
  if (_is == _it) _it = (_is = _buf) + fread(_buf, 1, 1048576, stdin);
  return *_is++;
}
inline void rdi(int &x) {
  int f = 0;
  register char ch = rdc();
  while ((ch < '0' or ch > '9') and (ch ^ '-')) ch = rdc();
  if (ch == '-') f = 1, ch = rdc();
  while (ch >= '0' and ch <= '9')
    x = (x << 3) + (x << 1) + (ch ^ '0'), ch = rdc();
  if (f) x = -x;
}
inline void rdi(long long &x) {
  long long f = 0;
  register char ch = rdc();
  while ((ch < '0' or ch > '9') and (ch ^ '-')) ch = rdc();
  if (ch == '-') f = 1, ch = rdc();
  while (ch >= '0' and ch <= '9')
    x = (x << 3) + (x << 1) + (ch ^ '0'), ch = rdc();
  if (f) x = -x;
}
inline void write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
inline void _write(int x) {
  write(x);
  putchar(' ');
}
inline void print(int x) {
  write(x);
  putchar('\n');
}
inline void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
inline void _write(long long x) {
  write(x);
  putchar(' ');
}
inline void print(long long x) {
  write(x);
  putchar('\n');
}
struct dsu {
  int par[200200];
  inline void init(int _n) {
    for (int i = 0; i < _n; ++i) par[i] = i;
  }
  inline int find(int now) {
    if (par[now] == now) return now;
    return par[now] = find(par[now]);
  }
  inline bool unite(int a, int b) {
    int Pa(find(a)), Pb(find(b));
    if (Pa == Pb) return false;
    par[Pa] = Pb;
    return true;
  }
};
const int N = 1048576;
long long t[N], d[N], res[N], m[N];
int n, q, par[N], a[N], h[N], nei[N], h2[N], nei2[N], v[N], u[N], l[N], r[N];
inline void up(int x) { t[x] = min(t[x << 1], t[x << 1 | 1]) + m[x]; }
inline void build(int x, int l, int r) {
  if (l == r) {
    t[x] = d[l];
    return;
  }
  int mid = l + r >> 1;
  build(x << 1, l, mid);
  build(x << 1 | 1, mid + 1, r);
  up(x);
}
inline void upd(int x, int l, int r, int L, int R, int d) {
  if (L <= l and r <= R) {
    t[x] += d;
    m[x] += d;
    return;
  }
  int mid = l + r >> 1;
  if (L <= mid) upd(x << 1, l, mid, L, R, d);
  if (R > mid) upd(x << 1 | 1, mid + 1, r, L, R, d);
  up(x);
}
long long query(int x, int l, int r, int L, int R) {
  if (L <= l and r <= R) return t[x];
  int md = l + r >> 1;
  long long mn = 1ll << 60;
  if (L <= md) mn = min(mn, query(x << 1, l, md, L, R));
  if (R > md) mn = min(mn, query(x << 1 | 1, md + 1, r, L, R));
  return mn + m[x];
}
inline void _upd(int x, int d) {
  upd(1, 1, n, 1, n, d);
  upd(1, 1, n, x, v[x], -(d << 1));
}
inline void dfs(int x) {
  _upd(x, a[x]);
  int i;
  for (i = h2[x]; i; i = nei2[i]) res[i] = query(1, 1, n, l[i], r[i]);
  for (i = h[x]; i; i = nei[i]) dfs(i);
  _upd(x, -a[x]);
}
int main() {
  int i, j;
  scanf("%d%d", &n, &q);
  for (i = 2; i <= n; i++) {
    scanf("%d%d", &par[i], &a[i]);
    d[i] = d[par[i]] + a[i];
    nei[i] = h[par[i]];
    h[par[i]] = i;
  }
  for (i = n; i; i--)
    if (h[i])
      v[i] = v[h[i]], d[i] = 1ll << 60;
    else
      v[i] = i;
  for (i = 1; i <= q; ++i)
    scanf("%d%d%d", &u[i], &l[i], &r[i]), nei2[i] = h2[u[i]], h2[u[i]] = i;
  build(1, 1, n);
  dfs(1);
  for (int i = 1; i <= q; i++) printf("%I64d\n", res[i]);
  return 0;
}
