#include <bits/stdc++.h>
using namespace std;
int n, q;
vector<int> e[555555];
long long res[555555];
int efn[555555], w[555555];
struct st {
  int ls, rs;
  long long mi, tag;
} a[1111111];
void pd(int x) {
  a[a[x].ls].mi += a[x].tag;
  a[a[x].ls].tag += a[x].tag;
  a[a[x].rs].mi += a[x].tag;
  a[a[x].rs].tag += a[x].tag;
  a[x].tag = 0;
}
void upd(int x) { a[x].mi = min(a[a[x].ls].mi, a[a[x].rs].mi); }
void C(int u, int cl, int cr, int l, int r, int x) {
  if (l <= cl && cr <= r) {
    a[u].mi += x;
    a[u].tag += x;
    return;
  }
  if (cr < l || r < cl) return;
  pd(u);
  int mid = (cl + cr) >> 1;
  C(a[u].ls, cl, mid, l, r, x);
  C(a[u].rs, mid + 1, cr, l, r, x);
  upd(u);
}
long long Q(int u, int cl, int cr, int l, int r) {
  if (l <= cl && cr <= r) {
    return a[u].mi;
  }
  if (cr < l || r < cl) return 1e18;
  pd(u);
  int mid = (cl + cr) >> 1;
  return min(Q(a[u].ls, cl, mid, l, r), Q(a[u].rs, mid + 1, cr, l, r));
}
struct query {
  int id, l, r;
};
vector<query> o[555555];
void dfs(int u) {
  for (vector<query>::iterator i = o[u].begin(); i != o[u].end(); ++i)
    res[i->id] = Q(1, 1, n, i->l, i->r);
  for (vector<int>::iterator i = e[u].begin(); i != e[u].end(); ++i) {
    int v = *i;
    C(1, 1, n, v, efn[v], -w[v]);
    C(1, 1, n, 1, v - 1, w[v]);
    C(1, 1, n, efn[v] + 1, n, w[v]);
    Q(1, 1, n, 1, 4);
    dfs(*i);
    C(1, 1, n, v, efn[v], w[v]);
    C(1, 1, n, 1, v - 1, -w[v]);
    C(1, 1, n, efn[v] + 1, n, -w[v]);
  }
}
long long dep[555555];
void init(int u, long long d) {
  efn[u] = u;
  dep[u] = d;
  for (vector<int>::iterator i = e[u].begin(); i != e[u].end(); ++i) {
    init(*i, d + w[*i]);
    efn[u] = efn[*i];
  }
}
int ca, d[555555];
int build(int l, int r) {
  int x = ++ca;
  if (l == r) {
    if (d[l] == 0)
      a[x].mi = dep[l];
    else
      a[x].mi = 1e18;
    return x;
  }
  int mid = (l + r) >> 1;
  a[x].ls = build(l, mid);
  a[x].rs = build(mid + 1, r);
  upd(x);
  return x;
}
int main() {
  !scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; ++i) {
    int p;
    !scanf("%d%d", &p, &w[i]);
    e[p].push_back(i);
    ++d[p];
  }
  for (int i = 1; i <= q; ++i) {
    int v, l, r;
    !scanf("%d%d%d", &v, &l, &r);
    o[v].push_back((query){i, l, r});
  }
  init(1, 0);
  build(1, n);
  dfs(1);
  for (int i = 1; i <= q; ++i) printf("%I64d\n", res[i]);
  return 0;
}
