#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;
const long long inf = 1e18 + 10;
long long L[N], R[N], ans[N], mn[4 * N], lz[4 * N], n, T;
vector<pair<int, int> > adj[N];
vector<pair<pair<int, int>, int> > qry[N];
void shift(int id) {
  long long x = lz[id];
  mn[id << 1] += x;
  lz[id << 1] += x;
  mn[id << 1 | 1] += x;
  lz[id << 1 | 1] += x;
  lz[id] = 0;
}
void modify(int p, long long x, int l = 0, int r = n, int id = 1) {
  if (r - l == 1) {
    mn[id] = x;
    return;
  }
  shift(id);
  int mid = l + r >> 1;
  if (p < mid)
    modify(p, x, l, mid, id << 1);
  else
    modify(p, x, mid, r, id << 1 | 1);
  mn[id] = min(mn[id << 1], mn[id << 1 | 1]);
}
void upd(int l, int r, long long x, int s = 0, int e = n, int id = 1) {
  if (e <= l || r <= s) return;
  if (l <= s && e <= r) {
    mn[id] += x;
    lz[id] += x;
    return;
  }
  shift(id);
  int mid = s + e >> 1;
  upd(l, r, x, s, mid, id << 1);
  upd(l, r, x, mid, e, id << 1 | 1);
  mn[id] = min(mn[id << 1], mn[id << 1 | 1]);
}
long long get(int l, int r, int s = 0, int e = n, int id = 1) {
  if (e <= l || r <= s) return inf;
  if (l <= s && e <= r) return mn[id];
  shift(id);
  int mid = s + e >> 1;
  return min(get(l, r, s, mid, id << 1), get(l, r, mid, e, id << 1 | 1));
}
void preDFS(int v, long long d = 0) {
  modify(T++, (adj[v].empty() ? d : inf));
  L[v] = T - 1;
  for (pair<int, int> e : adj[v]) preDFS(e.first, d + e.second);
  R[v] = T;
}
void DFS(int v, long long d = 0) {
  for (auto p : qry[v]) ans[p.second] = get(p.first.first, p.first.second);
  for (pair<int, int> e : adj[v]) {
    int u = e.first, w = e.second;
    upd(0, n, w);
    upd(L[u], R[u], -2 * w);
    DFS(u, d + w);
    upd(0, n, -w);
    upd(L[u], R[u], 2 * w);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> n >> q;
  for (int i = 2; i <= n; i++) {
    int p, w;
    cin >> p >> w;
    adj[p].push_back(make_pair(i, w));
  }
  for (int i = 0; i < q; i++) {
    int v, l, r;
    cin >> v >> l >> r;
    qry[v].push_back(make_pair(make_pair(l - 1, r), i));
  }
  preDFS(1);
  DFS(1);
  for (int i = 0; i < q; i++) cout << ans[i] << '\n';
  return 0;
}
