#include <bits/stdc++.h>
struct data {
  int v;
  long long w;
  data() {}
  data(int v_, long long w_) : v(v_), w(w_) {}
};
struct dl {
  int l, r, vt;
  dl() {}
  dl(int l_, int r_, int vt1) : l(l_), r(r_), vt(vt1) {}
};
const int maxn = 5e5 + 5;
const long long maxf = 1e18;
using namespace std;
int n, k, kq;
long long it[maxn * 8], la[maxn * 8], res[maxn], f[maxn], l[maxn], r[maxn],
    con[maxn];
vector<data> a[maxn];
vector<dl> b[maxn];
void enter() {
  int v, w, l, r;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= (n - 1); i++) {
    scanf("%d%d", &v, &w);
    a[v].emplace_back(i + 1, w);
  }
  for (int i = 1; i <= k; i++) {
    scanf("%d%d%d", &v, &l, &r);
    b[v].emplace_back(l, r, i);
  }
}
void dfs(int u) {
  int v;
  long long w;
  for (auto i = a[u].begin(); i != a[u].end(); i++) {
    con[u]++;
    v = (*i).v;
    w = (*i).w;
    f[v] = f[u] + w;
    dfs(v);
    l[u] = min(l[u], l[v]);
    r[u] = max(r[u], r[v]);
  }
  if (con[u] == 0) {
    l[u] = u;
    r[u] = u;
  }
}
void lazy(int k) {
  int t = la[k];
  la[k * 2] += t;
  it[k * 2] += t;
  la[k * 2 + 1] += t;
  it[k * 2 + 1] += t;
  la[k] = 0;
}
long long get(int k, int l, int r, int d, int c) {
  lazy(k);
  if (d > r || c < l) return (maxf);
  if (d <= l && c >= r) return (it[k]);
  int m = (l + r) / 2;
  long long t1 = get(k * 2, l, m, d, c);
  long long t2 = get(k * 2 + 1, m + 1, r, d, c);
  return (min(t1, t2));
}
void build(int k, int t, int p) {
  if (t == p) {
    if (con[t] == 0)
      it[k] = f[t];
    else
      it[k] = maxf;
    return;
  }
  int m = (t + p) / 2;
  build(k * 2, t, m);
  build(k * 2 + 1, m + 1, p);
  it[k] = min(it[k * 2], it[k * 2 + 1]);
}
void up(int k, int t, int p, int d, int c, long long x) {
  lazy(k);
  if (d > p || c < t) return;
  if (d <= t && c >= p) {
    it[k] += x;
    la[k] = x;
    return;
  }
  int m = (t + p) / 2;
  up(k * 2, t, m, d, c, x);
  up(k * 2 + 1, m + 1, p, d, c, x);
  it[k] = min(it[k * 2], it[k * 2 + 1]);
}
void dfs2(int u) {
  int v;
  dl t;
  long long ww;
  for (auto i = a[u].begin(); i != a[u].end(); i++) {
    v = (*i).v;
    ww = (*i).w;
    up(1, 1, n, l[v], r[v], -ww);
    if (l[v] - 1 > 0) up(1, 1, n, 1, l[v] - 1, ww);
    if (r[v] + 1 <= n) up(1, 1, n, r[v] + 1, n, ww);
    for (auto j = b[v].begin(); j != b[v].end(); j++) {
      t = *j;
      res[t.vt] = get(1, 1, n, t.l, t.r);
    }
    dfs2(v);
    up(1, 1, n, l[v], r[v], ww);
    if (l[v] - 1 > 0) up(1, 1, n, 1, l[v] - 1, -ww);
    if (r[v] + 1 <= n) up(1, 1, n, r[v] + 1, n, -ww);
  }
}
void solve() {
  for (int i = 1; i <= n; i++) {
    l[i] = maxf;
    r[i] = 0;
  }
  dfs(1);
  build(1, 1, n);
  dl t;
  for (auto i = b[1].begin(); i != b[1].end(); i++) {
    t = *i;
    res[t.vt] = get(1, 1, n, t.l, t.r);
  }
  dfs2(1);
  for (int i = 1; i <= k; i++) cout << res[i] << '\n';
}
int main() {
  enter();
  solve();
}
