#include <bits/stdc++.h>
inline int in() {
  int x, y;
  y = scanf("%d", &x);
  return x;
}
const int N = 1 << 19, S = 2 * N;
long long INF = 1e18;
long long ft[N], h[N], minLeafH[N];
vector<pair<int, long long>> g[N];
int node[N], l[N], r[N];
vector<int> qs[N];
long long lazy[S], mn[S];
long long res[N];
int n, q;
long long dfs(int v, long long depth = 0) {
  ft[v] = v;
  mn[v] = N;
  h[v] = depth;
  for (auto e : g[v]) {
    ft[v] = max(ft[v], dfs(e.first, depth + e.second));
    mn[v] = min(mn[v], mn[e.first]);
  }
  if (g[v].empty()) mn[v] = v;
  return ft[v];
}
void thunder(int id) {
  int v = lazy[id];
  mn[id * 2] += v;
  mn[id * 2 + 1] += v;
  lazy[id * 2] += v;
  lazy[id * 2 + 1] += v;
  lazy[id] = 0;
}
void add(int l, int r, long long val, int sl = 0, int sr = N, int id = 1) {
  int u = max(0, min(r, sr) - max(l, sl));
  if (u == sr - sl) {
    lazy[id] += val;
    mn[id] += val;
    return;
  }
  if (!u) return;
  int mid = (sl + sr) / 2;
  thunder(id);
  add(l, r, val, sl, mid, id * 2);
  add(l, r, val, mid, sr, id * 2 + 1);
  mn[id] = min(mn[id * 2], mn[id * 2 + 1]);
}
long long getMin(int l, int r, int sl = 0, int sr = N, int id = 1) {
  int u = max(0, min(r, sr) - max(l, sl));
  if (u == sr - sl) return mn[id];
  if (!u) return INF;
  int mid = (sl + sr) / 2;
  thunder(id);
  long long ret =
      min(getMin(l, r, sl, mid, id * 2), getMin(l, r, mid, sr, id * 2 + 1));
  return ret;
}
void solve(int v, long long w = 0) {
  add(v, ft[v] + 1, -w);
  add(0, v, w);
  add(ft[v] + 1, N, w);
  for (int q : qs[v]) {
    res[q] = getMin(l[q], r[q]);
  }
  for (auto e : g[v]) solve(e.first, e.second);
  add(v, ft[v] + 1, w);
  add(0, v, -w);
  add(ft[v] + 1, N, -w);
}
int main() {
  cin >> n >> q;
  for (int i = 1; i < n; i++) {
    int p = in() - 1, w = in();
    g[p].push_back({i, w});
  }
  dfs(0);
  fill(mn, mn + S, INF);
  for (int i = 0; i < n; i++)
    if (g[i].empty()) {
      mn[i + N] = h[i];
    }
  for (int i = N - 1; i > 0; i--) mn[i] = min(mn[i * 2], mn[i * 2 + 1]);
  for (int i = 0; i < q; i++) {
    qs[node[i] = in() - 1].push_back(i);
    l[i] = in() - 1;
    r[i] = in();
  }
  solve(0);
  for (int i = 0; i < q; i++) cout << res[i] << "\n";
}
