#include <bits/stdc++.h>
using namespace std;
const long long int inf = 1LL << 60;
const int MAXN = 1000001;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int sz = 0;
int ini[MAXN];
int fin[MAXN];
long long int ans[MAXN];
long long int num[MAXN];
vector<pair<int, int> > lista[MAXN];
vector<pair<int, pair<int, int> > > question[MAXN];
struct Segment {
  int l, r;
  long long int val, lazy;
  Segment *left, *right;
  Segment() {}
  Segment(int a, int b)
      : l(a), r(b), left(NULL), right(NULL), val(inf), lazy(-inf) {}
  void build() {
    if (l == r) {
      val = num[l];
      return;
    }
    int med = (l + r) / 2;
    (left = new Segment(l, med))->build();
    (right = new Segment(med + 1, r))->build();
    val = min(left->val, right->val);
  }
  void reset(long long int v) {
    if (lazy == -inf)
      lazy = v;
    else
      lazy += v;
  }
  void go() {
    if (lazy != -inf) {
      left->val += lazy;
      left->reset(lazy);
      right->val += lazy;
      right->reset(lazy);
      lazy = -inf;
    }
  }
  void update(int a, int b, long long int v) {
    if (b < l || a > r) return;
    if (a <= l && r <= b) {
      val += v;
      reset(v);
      return;
    }
    go();
    left->update(a, b, v);
    right->update(a, b, v);
    val = min(left->val, right->val);
  }
  long long int query(int a, int b) {
    if (b < l || a > r) return inf;
    if (a <= l && r <= b) return val;
    go();
    return min(left->query(a, b), right->query(a, b));
  }
};
Segment *tree;
void build(int u = 0, long long int d = 0) {
  ini[u] = sz++;
  for (auto v : lista[u]) build(v.first, d + v.second);
  fin[u] = sz - 1;
  if (!lista[u].size()) num[ini[u]] = d;
}
void solve(int u = 0) {
  for (auto q : question[u])
    ans[q.first] = tree->query(q.second.first, q.second.second);
  for (auto v : lista[u]) {
    tree->update(0, ini[v.first] - 1, v.second);
    tree->update(ini[v.first], fin[v.first], -v.second);
    tree->update(fin[v.first] + 1, sz - 1, v.second);
    solve(v.first);
    tree->update(0, ini[v.first] - 1, -v.second);
    tree->update(ini[v.first], fin[v.first], v.second);
    tree->update(fin[v.first] + 1, sz - 1, -v.second);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, q, a, l, r, d;
  cin >> n >> q;
  for (int i = 1; i < n; i++) {
    cin >> a >> d;
    lista[a - 1].emplace_back(i, d);
  }
  for (int i = 0; i < q; i++) {
    cin >> a >> l >> r;
    a--, l--, r--;
    question[a].emplace_back(i, pair<int, int>(l, r));
  }
  fill(num, num + MAXN, inf);
  build();
  (tree = new Segment(0, sz - 1))->build();
  solve();
  for (int i = 0; i < q; i++) cout << ans[i] << '\n';
  return 0;
}
