#include <bits/stdc++.h>
using namespace std;
const long long inf = 5e18;
struct segtree;
using np = segtree*;
struct segtree {
  np l, r;
  int sz;
  long long mi, lz;
  segtree(int sz) : sz(sz) {
    lz = 0;
    mi = inf;
    if (sz == 1) {
      return;
    }
    l = new segtree(sz / 2);
    r = new segtree(sz - sz / 2);
  }
  void apply(long long d) {
    mi += d;
    lz += d;
  }
  void push() {
    l->apply(lz);
    r->apply(lz);
    lz = 0;
  }
  void pull() { mi = min(l->mi, r->mi); }
  void set(int k, long long v) {
    if (sz == 1) {
      mi = v;
      return;
    }
    push();
    if (k < sz / 2) {
      l->set(k, v);
    } else {
      r->set(k - sz / 2, v);
    }
    pull();
  }
  void add(int a, int b, long long d) {
    if (b <= 0 || sz <= a) {
      return;
    }
    if (a <= 0 && sz <= b) {
      apply(d);
      return;
    }
    push();
    l->add(a, b, d);
    r->add(a - sz / 2, b - sz / 2, d);
    pull();
  }
  long long get(int a, int b) {
    if (b <= 0 || sz <= a) {
      return inf;
    }
    if (a <= 0 && sz <= b) {
      return mi;
    }
    push();
    return min(l->get(a, b), r->get(a - sz / 2, b - sz / 2));
  }
};
struct query {
  int l, r, id;
};
const int N = 500010;
int n, m;
vector<query> vec[N];
np st;
long long res[N];
long long w[N];
vector<int> g[N];
int mx[N];
void dfs1(int v, long long d) {
  if (g[v].empty()) {
    mx[v] = v;
    st->set(v, d);
    assert(st->get(v, v + 1) == d);
    return;
  }
  for (int u : g[v]) {
    dfs1(u, d + w[u]);
    mx[v] = max(mx[v], mx[u]);
  }
}
void dfs2(int v) {
  for (auto& q : vec[v]) {
    res[q.id] = st->get(q.l, q.r);
  }
  for (int u : g[v]) {
    st->add(u, mx[u] + 1, -w[u]);
    st->add(0, u, w[u]);
    st->add(mx[u] + 1, n, w[u]);
    dfs2(u);
    st->add(u, mx[u] + 1, w[u]);
    st->add(0, u, -w[u]);
    st->add(mx[u] + 1, n, -w[u]);
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i < n; i++) {
    int p;
    scanf("%d %lld", &p, &w[i]);
    p--;
    g[p].push_back(i);
  }
  st = new segtree(n);
  dfs1(0, 0);
  for (int i = 0; i < m; i++) {
    int v, l, r;
    scanf("%d %d %d", &v, &l, &r);
    v--;
    l--;
    vec[v].push_back(query{l, r, i});
  }
  dfs2(0);
  for (int i = 0; i < m; i++) {
    printf("%lld\n", res[i]);
  }
  return 0;
}
