#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
int n, Q, x;
int fa[N], fv[N];
vector<int> c[N];
struct nod {
  int i, l, r;
} b;
vector<nod> a[N];
int pl, pr;
long long px;
long long t[N * 4], lz[N * 4];
void down(int i) {
  if (lz[i]) {
    t[i + i] += lz[i];
    lz[i + i] += lz[i];
    t[i + i + 1] += lz[i];
    lz[i + i + 1] += lz[i];
    lz[i] = 0;
  }
}
void add(int i, int x, int y) {
  if (y < pl || x > pr) return;
  if (x >= pl && y <= pr) {
    t[i] += px;
    lz[i] += px;
    return;
  }
  int m = x + y >> 1;
  down(i);
  add(i + i, x, m);
  add(i + i + 1, m + 1, y);
  t[i] = min(t[i + i], t[i + i + 1]);
}
void ft(int i, int x, int y) {
  if (y < pl || x > pr) return;
  if (x >= pl && y <= pr) {
    px = min(px, t[i]);
    return;
  }
  int m = x + y >> 1;
  down(i);
  ft(i + i, x, m);
  ft(i + i + 1, m + 1, y);
}
int p[N], q[N], tp;
long long s[N];
const long long M = 1e18;
void dg(int x) {
  p[x] = ++tp;
  for (int j = 0, B = c[x].size() - 1; j <= B; j++) {
    int y = c[x][j];
    s[y] = s[x] + fv[y], dg(y);
  }
  q[x] = tp;
  if (p[x] == q[x]) {
    pl = pr = p[x];
    px = s[x] - M;
    add(1, 1, n);
  }
}
long long ans[N];
void dfs(int x) {
  for (int j = 0, B = a[x].size() - 1; j <= B; j++) {
    pl = a[x][j].l, pr = a[x][j].r;
    px = 1e18;
    ft(1, 1, n);
    ans[a[x][j].i] = px;
  }
  for (int j = 0, B = c[x].size() - 1; j <= B; j++) {
    int y = c[x][j];
    px = -fv[y];
    pl = p[y];
    pr = q[y];
    add(1, 1, n);
    px = fv[y];
    pl = 1;
    pr = p[y] - 1;
    add(1, 1, n);
    pl = q[y] + 1;
    pr = n;
    add(1, 1, n);
    dfs(y);
    px = -fv[y];
    pl = q[y] + 1;
    pr = n;
    add(1, 1, n);
    pl = 1;
    pr = p[y] - 1;
    add(1, 1, n);
    px = fv[y];
    pl = p[y];
    pr = q[y];
    add(1, 1, n);
  }
}
int main() {
  scanf("%d %d", &n, &Q);
  for (int i = 1, B = n * 4; i <= B; i++) t[i] = 1e18;
  for (int i = 2, B = n; i <= B; i++) {
    scanf("%d %d", &fa[i], &fv[i]);
    c[fa[i]].push_back(i);
  }
  for (int i = 1, B = Q; i <= B; i++) {
    scanf("%d", &x);
    scanf("%d %d", &b.l, &b.r);
    b.i = i;
    a[x].push_back(b);
  }
  dg(1);
  dfs(1);
  for (int i = 1, B = Q; i <= B; i++) printf("%I64d\n", ans[i]);
}
