#include <bits/stdc++.h>
using namespace std;
const long long N = 5e5 + 5, INF = 1e18;
long long n, x, y, z, mx[N], q, tree[N << 2], c[N], lz[N << 2], out[N];
vector<vector<pair<int, long long> > > adj(N);
vector<vector<pair<pair<int, int>, int> > > qr(N);
void build(int s = 1, int e = n, int idx = 1) {
  if (s == e) {
    tree[idx] = (adj[s].size()) ? INF : c[s];
    return;
  }
  int md = (s + e) >> 1;
  build(s, md, idx << 1);
  build(md + 1, e, idx << 1 | 1);
  tree[idx] = min(tree[idx << 1], tree[idx << 1 | 1]);
}
void push(int l, int r, int idx) {
  if (l == r || !lz[idx]) return;
  tree[idx << 1] += lz[idx];
  tree[idx << 1 | 1] += lz[idx];
  lz[idx << 1] += lz[idx];
  lz[idx << 1 | 1] += lz[idx];
  lz[idx] = 0;
}
void udt(int l, int r, long long val, int s = 1, int e = n, int idx = 1) {
  push(s, e, idx);
  if (l == s && r == e) {
    tree[idx] += val;
    lz[idx] += val;
    return;
  }
  int md = (s + e) >> 1;
  if (l <= md) udt(l, min(md, r), val, s, md, idx << 1);
  if (r > md) udt(max(l, md + 1), r, val, md + 1, e, idx << 1 | 1);
  tree[idx] = min(tree[idx << 1], tree[idx << 1 | 1]);
}
long long get(int l, int r, int s = 1, int e = n, int idx = 1) {
  push(s, e, idx);
  if (l == s && r == e) return tree[idx];
  int md = (s + e) >> 1;
  long long re = INF;
  if (l <= md) re = min(re, get(l, min(md, r), s, md, idx << 1));
  if (r > md) re = min(re, get(max(md + 1, l), r, md + 1, e, idx << 1 | 1));
  return re;
}
void dfs_set(int u = 1) {
  mx[u] = u;
  for (auto i : adj[u]) {
    int v = i.first;
    long long w = i.second;
    c[v] = c[u] + w;
    dfs_set(v);
    mx[u] = max(mx[u], mx[v]);
  }
}
void udt(int u, long long w) {
  udt(u, mx[u], -w);
  if (u > 1) udt(1, u - 1, w);
  if (mx[u] < n) udt(mx[u] + 1, n, w);
}
void dfs_solve(int u = 1) {
  for (auto i : qr[u]) {
    int l = i.first.first;
    int r = i.first.second;
    int j = i.second;
    out[j] = get(l, r);
  }
  for (auto i : adj[u]) {
    int v = i.first;
    long long w = i.second;
    udt(v, w);
    dfs_solve(v);
    udt(v, -w);
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> q;
  for (int i = 2; i <= n; i++) {
    cin >> x >> y;
    adj[x].push_back({i, y});
  }
  for (int i = 0; i < q; i++) {
    cin >> x >> y >> z;
    qr[x].push_back({{y, z}, i});
  }
  dfs_set();
  build();
  dfs_solve();
  for (int i = 0; i < q; i++) cout << out[i] << '\n';
  return 0;
}
