#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int, int>>> G;
vector<vector<pair<int, pair<int, int>>>> que;
vector<int> vis;
vector<int> start;
vector<int> finish;
int num_id = 1;
long long inf = 1LL << 60;
vector<long long> spa;
vector<long long> drz;
vector<long long> ans;
int n2;
void insert(int x, long long w) {
  int v = x + n2;
  while (v > 0) {
    drz[v] = min(w, drz[v]);
    v /= 2;
  }
}
void dfs(int x, long long w) {
  vis[x] = 1;
  start[x] = num_id;
  num_id++;
  sort(G[x].begin(), G[x].end());
  for (auto e : G[x]) {
    int y, f;
    tie(y, f) = e;
    if (vis[y] == 0) dfs(y, w + f);
  }
  finish[x] = num_id - 1;
  if (G[x].size() == 1) insert(start[x], w);
}
void spada(int x) {
  drz[x] += spa[x];
  if (x < n2) {
    spa[2 * x] += spa[x];
    spa[2 * x + 1] += spa[x];
  }
  spa[x] = 0;
}
long long czytaj(int v, int p, int k, int a, int b) {
  spada(v);
  if (k <= a || b <= p) return inf;
  if (a <= p && k <= b) return drz[v];
  int s = (p + k) / 2;
  return min(czytaj(2 * v, p, s, a, b), czytaj(2 * v + 1, s, k, a, b));
}
void dodaj(int v, int p, int k, int a, int b, int d) {
  spada(v);
  if (k <= a || b <= p) return;
  if (a <= p && k <= b) {
    spa[v] += d;
    spada(v);
    return;
  }
  int s = (p + k) / 2;
  dodaj(2 * v, p, s, a, b, d);
  dodaj(2 * v + 1, s, k, a, b, d);
  drz[v] = min(drz[2 * v], drz[2 * v + 1]);
}
void answers(int x) {
  cout << "ANS " << x << " " << start[x] << " " << finish[x] << "\n";
  vis[x] = 2;
  for (int i = 0; i < 2 * n2; i++) {
    cout << i << ":" << spa[i] << " _ " << drz[i] << " | ";
  }
  cout << "\n";
  for (auto q : que[x]) {
    int id;
    pair<int, int> lr;
    tie(id, lr) = q;
    ans[id] = czytaj(1, 0, n2, lr.first, lr.second + 1);
  }
  for (auto e : G[x]) {
    int y, f;
    tie(y, f) = e;
    if (vis[y] != 2) {
      spa[1] += f;
      dodaj(1, 0, n2, start[y], finish[y] + 1, -2 * f);
      answers(y);
      spa[1] -= f;
      dodaj(1, 0, n2, start[y], finish[y] + 1, 2 * f);
    }
  }
}
int main() {
  int n, q;
  cin >> n >> q;
  G.resize(n + 1);
  for (int i = 2; i <= n; i++) {
    int x, w;
    cin >> x >> w;
    G[x].emplace_back(i, w);
    G[i].emplace_back(x, w);
  }
  que.resize(n + 1);
  for (int i = 0; i < q; i++) {
    int v, l, r;
    cin >> v >> l >> r;
    que[v].emplace_back(i, make_pair(l, r));
  }
  ans.resize(q);
  vis.resize(n + 1);
  start.resize(n + 1);
  finish.resize(n + 1);
  n2 = 1;
  while (n2 <= n) n2 *= 2;
  drz.resize(n2 * 2 + 5, inf);
  spa.resize(n2 * 2 + 5, 0);
  dfs(1, 0);
  answers(1);
  for (long long x : ans) cout << x << "\n";
}
