#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int N = 500 * 1000 + 10;
const ll INF = 1e18;
int n, q, mx[N];
vector<pii> adj[N];
vector<tuple<int, int, int>> query[N];
ll a[N];
struct node {
  ll mn, lazy;
  node() { mn = 0, lazy = 0; }
} seg[N << 2];
void fill_seg(int v = 0, ll dis = 0) {
  a[v] = INF, mx[v] = v + 1;
  for (auto [u, w] : adj[v]) fill_seg(u, dis + w), mx[v] = max(mx[v], mx[u]);
  if (adj[v].empty()) a[v] = dis;
}
void build(int l = 0, int r = n, int id = 1) {
  if (r - l == 1) return seg[id].mn = a[l], void();
  int mid = l + r >> 1;
  build(l, mid, id << 1), build(mid, r, id << 1 | 1);
  seg[id].mn = min(seg[id << 1].mn, seg[id << 1 | 1].mn);
}
void push(int id) {
  if (seg[id << 1].mn ^ INF)
    seg[id << 1].mn += seg[id].lazy, seg[id << 1].lazy += seg[id].lazy;
  if (seg[id << 1 | 1].mn ^ INF)
    seg[id << 1 | 1].mn += seg[id].lazy, seg[id << 1 | 1].lazy += seg[id].lazy;
  seg[id].lazy = 0;
}
void upd(int lq, int rq, int w, int l = 0, int r = n, int id = 1) {
  if (rq <= l || r <= lq) return;
  if (lq <= l && r <= rq) {
    if (seg[id].mn ^ INF) seg[id].mn += w, seg[id].lazy += w;
    return;
  }
  push(id);
  int mid = l + r >> 1;
  upd(lq, rq, w, l, mid, id << 1), upd(lq, rq, w, mid, r, id << 1 | 1);
  seg[id].mn = min(seg[id << 1].mn, seg[id << 1 | 1].mn);
}
ll get(int lq, int rq, int l = 0, int r = n, int id = 1) {
  if (rq <= l || r <= lq) return INF;
  if (lq <= l && r <= rq) return seg[id].mn;
  push(id);
  int mid = l + r >> 1;
  return min(get(lq, rq, l, mid, id << 1), get(lq, rq, mid, r, id << 1 | 1));
}
void dfs(int v = 0, int W = 0) {
  upd(v, mx[v], -W);
  upd(0, v, W), upd(mx[v], n, W);
  for (auto [l, r, ind] : query[v]) a[ind] = get(l, r);
  for (auto [u, w] : adj[v]) dfs(u, w);
  upd(v, mx[v], W);
  upd(0, v, -W), upd(mx[v], n, -W);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  cin >> n >> q;
  for (int i = 1, p, w; i < n; i++) cin >> p >> w, adj[--p].push_back({i, w});
  int v, l, r;
  for (int i = 0; i < q; i++)
    cin >> v >> l >> r, query[--v].push_back({--l, r, i});
  fill_seg();
  build();
  dfs();
  for (int i = 0; i < q; i++) cout << a[i] << '\n';
}
