#include <bits/stdc++.h>
using namespace std;
const int N = 5e5;
const int M = N + 17;
const int K = 4 * N + 17;
const int MOD = 1e9 + 7;
const long long INF = 1e16 + 17;
long long tree[K], add[K];
vector<pair<int, long long> > ord;
void push(int v, int tl, int tr) {
  tree[v] += add[v];
  if (tl != tr) {
    add[v << 1] += add[v];
    add[v << 1 | 1] += add[v];
  }
  add[v] = 0;
}
long long getMin(int l, int r, int v = 1, int tl = 1,
                 int tr = (int)ord.size()) {
  push(v, tl, tr);
  if (tr < l || r < tl) return INF;
  if (l <= tl && tr <= r) return tree[v];
  int tm = (tl + tr) >> 1;
  long long left = getMin(l, r, v << 1, tl, tm);
  long long right = getMin(l, r, v << 1 | 1, tm + 1, tr);
  return min(left, right);
}
void upd(int l, int r, long long val, int v = 1, int tl = 1,
         int tr = (int)ord.size()) {
  push(v, tl, tr);
  if (tr < l || r < tl) return;
  if (l <= tl && tr <= r) {
    add[v] += val;
    push(v, tl, tr);
    return;
  }
  int tm = (tl + tr) >> 1;
  upd(l, r, val, v << 1, tl, tm);
  upd(l, r, val, v << 1 | 1, tm + 1, tr);
  tree[v] = min(tree[v << 1], tree[v << 1 | 1]);
}
int listL[K], listR[K];
vector<pair<int, int> > edges[M];
vector<pair<pair<int, int>, int> > queries[M];
void dfs(int v, long long dist = 0) {
  if (edges[v].empty()) {
    ord.push_back(make_pair(v, dist));
    listL[v] = (int)ord.size();
    listR[v] = (int)ord.size();
    return;
  }
  for (int i = 0; i < (int)edges[v].size(); ++i) {
    int to = edges[v][i].first, w = edges[v][i].second;
    dfs(to, dist + w);
    listL[v] = min(listL[v], listL[to]);
    listR[v] = max(listR[v], listR[to]);
  }
}
long long ans[M];
void calcAnswer(int v, int last = 0) {
  for (int i = 0; i < (int)queries[v].size(); ++i) {
    int l = queries[v][i].first.first, r = queries[v][i].first.second;
    int id = queries[v][i].second;
    ans[id] = getMin(l, r);
  }
  for (int i = 0; i < (int)edges[v].size(); ++i) {
    int to = edges[v][i].first, w = edges[v][i].second;
    int l = listL[to], r = listR[to];
    upd(l, r, -w);
    upd(1, l - 1, w);
    upd(r + 1, (int)ord.size(), w);
    calcAnswer(to, w);
  }
  int l = listL[v], r = listR[v];
  upd(l, r, last);
  upd(1, l - 1, -last);
  upd(r + 1, (int)ord.size(), -last);
}
int pL[M], pR[M];
int main() {
  for (int i = 0; i < M; ++i) listL[i] = MOD;
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 2; i <= n; ++i) {
    int v, w;
    scanf("%d %d", &v, &w);
    edges[v].push_back(make_pair(i, w));
  }
  dfs(1);
  for (int i = 0; i < (int)ord.size(); ++i) {
    int v = ord[i].first, dist = ord[i].second;
    upd(i + 1, i + 1, dist);
    pL[v] = pR[v] = i + 1;
  }
  for (int i = 1; i <= n; ++i) pR[i] = (pR[i] ? pR[i] : pR[i - 1]);
  for (int i = n; i >= 1; --i) pL[i] = (pL[i] ? pL[i] : pL[i + 1]);
  for (int i = 1; i <= m; ++i) {
    int v, l, r;
    scanf("%d %d %d", &v, &l, &r);
    l = pL[l];
    r = pR[r];
    queries[v].push_back(make_pair(make_pair(l, r), i));
  }
  calcAnswer(1);
  for (int i = 1; i <= m; ++i) printf("%lld\n", ans[i]);
  return 0;
}
