#include <bits/stdc++.h>
using namespace std;
int solve();
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
const int MAXN = (int)5e5 + 10;
const long long INF = (long long)1e16;
vector<pair<int, int>> g[MAXN];
vector<pair<pair<int, int>, int>> quest[MAXN];
long long ans[MAXN];
long long t[4 * MAXN];
long long mod[4 * MAXN];
long long a[MAXN];
int tin[MAXN], tout[MAXN];
int n, q;
void push(int v) {
  if (t[2 * v] != INF) {
    t[2 * v] += mod[v];
    mod[2 * v] += mod[v];
  }
  if (t[2 * v + 1] != INF) {
    t[2 * v + 1] += mod[v];
    mod[2 * v + 1] += mod[v];
  }
  mod[v] = 0;
  return;
}
void update(int v, int tl, int tr, int l, int r, long long val) {
  if (tl > r || tr < l) return;
  if (tl >= l && tr <= r) {
    if (t[v] == INF) return;
    t[v] += val;
    mod[v] += val;
    return;
  }
  push(v);
  int tm = (tl + tr) / 2;
  update(2 * v, tl, tm, l, r, val);
  update(2 * v + 1, tm + 1, tr, l, r, val);
  t[v] = min(t[2 * v], t[2 * v + 1]);
  return;
}
void build(int v, int p, long long cur) {
  if ((int)g[v].size() == 1) {
    tin[v] = v;
    tout[v] = v;
    a[v] = cur;
    return;
  } else
    a[v] = INF;
  for (int i = 0; i < (int)g[v].size(); i++)
    if (g[v][i].first != p) {
      build(g[v][i].first, v, cur + g[v][i].second);
      if (tin[v] == 0) tin[v] = tin[g[v][i].first];
      tout[v] = tout[g[v][i].first];
    }
  return;
}
void build_tree(int v, int tl, int tr) {
  if (tl == tr) {
    t[v] = a[tl];
    return;
  }
  int tm = (tl + tr) / 2;
  build_tree(2 * v, tl, tm);
  build_tree(2 * v + 1, tm + 1, tr);
  t[v] = min(t[2 * v], t[2 * v + 1]);
  return;
}
long long get(int v, int tl, int tr, int l, int r) {
  if (tl > r || tr < l) return INF;
  if (tl >= l && tr <= r) {
    return t[v];
  }
  push(v);
  int tm = (tl + tr) / 2;
  return min(get(2 * v, tl, tm, l, r), get(2 * v + 1, tm + 1, tr, l, r));
}
void dfs(int v, int p = -1) {
  for (int i = 0; i < (int)quest[v].size(); i++) {
    ans[quest[v][i].second] =
        get(1, 1, n, quest[v][i].first.first, quest[v][i].first.second);
  }
  for (int i = 0; i < (int)g[v].size(); i++)
    if (g[v][i].first != p) {
      update(1, 1, n, 1, n, g[v][i].second);
      update(1, 1, n, tin[g[v][i].first], tout[g[v][i].first],
             -2 * g[v][i].second);
      dfs(g[v][i].first, v);
      update(1, 1, n, 1, n, -g[v][i].second);
      update(1, 1, n, tin[g[v][i].first], tout[g[v][i].first],
             2 * g[v][i].second);
    }
  return;
}
int solve() {
  cin >> n >> q;
  for (int i = 2; i <= n; i++) {
    int x, w;
    cin >> x >> w;
    g[x].push_back(make_pair(i, w));
    g[i].push_back(make_pair(x, w));
  }
  for (int i = 0; i < q; i++) {
    int v, l, r;
    cin >> v >> l >> r;
    quest[v].push_back(make_pair(make_pair(l, r), i));
  }
  build(1, -1, 0);
  build_tree(1, 1, n);
  dfs(1);
  for (int i = 0; i < q; i++) cout << ans[i] << '\n';
  return 0;
}
