#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 233;
const long long inf = 1LL << 60;
int l[maxn], r[maxn];
long long ans[maxn], a[maxn], d[maxn];
vector<int> g[maxn], w[maxn], q[maxn];
struct seg_tree {
  long long ch[maxn * 4], val[maxn * 4];
  void add(int l, int r, int cur, int x, int y, int v) {
    if (x <= l && r <= y) {
      val[cur] += v;
      ch[cur] += v;
      return;
    }
    if (r < x || l > y) return;
    int mid = (l + r) >> 1, lc = cur << 1, rc = lc | 1;
    add(l, mid, lc, x, y, v);
    add(mid + 1, r, rc, x, y, v);
    ch[cur] = min(ch[lc], ch[rc]) + val[cur];
    return;
  }
  long long query(int l, int r, int cur, int x, int y) {
    if (x <= l && r <= y) return ch[cur];
    if (r < x || l > y) return inf;
    int mid = (l + r) >> 1, lc = cur << 1, rc = lc | 1;
    return min(query(l, mid, lc, x, y), query(mid + 1, r, rc, x, y)) + val[cur];
  }
  void init() {
    memset(ch, 0, sizeof(ch));
    memset(val, 0, sizeof(val));
  }
  void build(int l, int r, int cur) {
    if (l == r) {
      ch[cur] = a[l];
      return;
    }
    int mid = (l + r) >> 1, lc = cur << 1, rc = lc | 1;
    build(l, mid, lc);
    build(mid + 1, r, rc);
    ch[cur] = min(ch[lc], ch[rc]);
  }
} seg;
int last[maxn], n;
void dfs2(int x) {
  for (int i = 0; i < q[x].size(); i++) {
    int t = q[x][i];
    ans[t] = seg.query(1, n, 1, l[t], r[t]) + d[x];
  }
  for (int i = 0; i < g[x].size(); i++) {
    int y = g[x][i];
    seg.add(1, n, 1, y, last[y], -2 * w[x][i]);
    dfs2(y);
    seg.add(1, n, 1, y, last[y], 2 * w[x][i]);
  }
}
void dfs1(int x) {
  last[x] = x;
  a[x] = d[x];
  for (int i = 0; i < g[x].size(); i++) {
    int y = g[x][i];
    d[y] = d[x] + w[x][i];
    dfs1(y);
    last[x] = last[y];
    a[x] = inf;
  }
}
int main() {
  int Q;
  cin >> n >> Q;
  for (int i = 2; i <= n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    g[x].push_back(i);
    w[x].push_back(y);
  }
  for (int i = 1; i <= Q; i++) {
    int x;
    scanf("%d%d%d", &x, &l[i], &r[i]);
    q[x].push_back(i);
  }
  dfs1(1);
  seg.build(1, n, 1);
  dfs2(1);
  for (int i = 1; i <= Q; i++) printf("%lld\n", ans[i]);
  return 0;
}
