#include <bits/stdc++.h>
using namespace std;
long long n, q;
long long read() {
  long long x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x;
}
struct edge {
  long long v, w, next;
} e[500010 << 1];
long long eid, p[500010 << 1];
void insert(long long u, long long v, long long w) {
  e[++eid] = {v, w, p[u]};
  p[u] = eid;
}
struct node {
  long long l, r, num;
};
vector<node> que[500010];
long long dis[500010], size[500010];
bool leaf[500010];
void dfs(long long u, long long f, long long x) {
  dis[u] = x, size[u] = 1, leaf[u] = 1;
  for (long long i = p[u]; i; i = e[i].next) {
    long long v = e[i].v;
    if (v != f) leaf[u] = 0, dfs(v, u, x + e[i].w), size[u] += size[v];
  }
}
namespace SEG {
long long minn[500010 << 2], tag[500010 << 2];
void up(long long p) { minn[p] = min(minn[p << 1], minn[p << 1 | 1]); }
void down(long long p) {
  if (!tag[p]) return;
  minn[p << 1] += tag[p], minn[p << 1 | 1] += tag[p];
  tag[p << 1] += tag[p], tag[p << 1 | 1] += tag[p];
  tag[p] = 0;
}
void build(long long p, long long l, long long r) {
  minn[p] = 1e18;
  if (l == r) {
    if (leaf[l]) minn[p] = dis[l];
    return;
  }
  long long mid = (l + r) >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
  up(p);
}
void change(long long p, long long l, long long r, long long x, long long y,
            long long c) {
  if (l >= x && r <= y) {
    minn[p] += c;
    tag[p] += c;
    return;
  }
  down(p);
  long long mid = (l + r) >> 1;
  if (x <= mid) change(p << 1, l, mid, x, y, c);
  if (y > mid) change(p << 1 | 1, mid + 1, r, x, y, c);
  up(p);
}
long long query(long long p, long long l, long long r, long long x,
                long long y) {
  if (l >= x && r <= y) return minn[p];
  down(p);
  long long mid = (l + r) >> 1;
  if (y <= mid) return query(p << 1, l, mid, x, y);
  if (x > mid) return query(p << 1 | 1, mid + 1, r, x, y);
  return min(query(p << 1, l, mid, x, y), query(p << 1 | 1, mid + 1, r, x, y));
}
}  // namespace SEG
long long res[500010];
void ans(long long u, long long f, long long x) {
  SEG::change(1, 1, n, 1, n, x);
  SEG::change(1, 1, n, u, u + size[u] - 1, -2 * x);
  for (long long i = 0; i < que[u].size(); ++i)
    res[que[u][i].num] = SEG::query(1, 1, n, que[u][i].l, que[u][i].r);
  for (long long i = p[u]; i; i = e[i].next) {
    long long v = e[i].v;
    if (v != f) ans(v, u, e[i].w);
  }
  SEG::change(1, 1, n, 1, n, -x);
  SEG::change(1, 1, n, u, u + size[u] - 1, 2 * x);
}
int main() {
  cin >> n >> q;
  for (long long i = 2; i <= n; ++i) {
    long long v = read(), w = read();
    insert(i, v, w);
    insert(v, i, w);
  }
  for (long long i = 1; i <= q; ++i) {
    long long u = read(), l = read(), r = read();
    que[u].push_back({l, r, i});
  }
  dfs(1, 1, 0);
  SEG::build(1, 1, n);
  ans(1, 1, 0);
  for (long long i = 1; i <= q; ++i) cout << res[i] << " ";
  return 0;
}
