#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10, mod = 1e9 + 7;
long long n, q, ans[N], w[N], seg[4 * N], st[N], ft[N], now = 0;
vector<long long> g[N];
vector<pair<pair<long long, long long>, long long>> qq[N];
void build(long long s, long long e, long long ind, long long l, long long r,
           long long val) {
  if (s >= r || e <= l) return;
  if (s >= l && e <= r) {
    seg[ind] = val;
    return;
  }
  long long mid = (s + e) / 2;
  build(s, mid, 2 * ind, l, r, val);
  build(mid, e, 2 * ind + 1, l, r, val);
  seg[ind] = min(seg[2 * ind], seg[2 * ind + 1]);
}
void add(long long s, long long e, long long ind, long long l, long long r,
         long long val) {
  if (s >= r || e <= l) return;
  if (s >= l && e <= r) {
    seg[ind] += val;
    return;
  }
  long long mid = (s + e) / 2;
  add(s, mid, 2 * ind, l, r, val);
  add(mid, e, 2 * ind + 1, l, r, val);
  seg[ind] = min(seg[2 * ind], seg[2 * ind + 1]);
}
long long get(long long s, long long e, long long ind, long long l,
              long long r) {
  if (s >= r || e <= l) return 1ll * mod * mod;
  if (s >= l && e <= r) {
    return seg[ind];
  }
  long long mid = (s + e) / 2;
  long long x = get(s, mid, 2 * ind, l, r);
  long long y = get(mid, e, 2 * ind + 1, l, r);
  return min(x, y);
}
void predfs(long long v, long long d) {
  st[v] = now++;
  for (long long u : g[v]) predfs(u, d + w[u]);
  ft[v] = now;
  if (g[v].size() == 0) build(0, n, 1, st[v], st[v] + 1, d);
}
void dfs(long long v) {
  for (auto xx : qq[v]) {
    long long l = xx.first.first, r = xx.first.second, id = xx.second;
    ans[id] = get(0, n, 1, l, r);
  }
  for (long long u : g[v]) {
    add(0, n, 1, 0, n, w[u]);
    add(0, n, 1, st[u], ft[u], -2 * w[u]);
    dfs(u);
    add(0, n, 1, 0, n, -w[u]);
    add(0, n, 1, st[u], ft[u], +2 * w[u]);
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  for (long long i = 0; i < n; i++) build(0, n, 1, i, i + 1, 1ll * mod * mod);
  for (long long i = 1; i < n; i++) {
    long long p;
    cin >> p >> w[i];
    p--;
    g[p].push_back(i);
  }
  predfs(0, 0);
  for (long long i = 0; i < q; i++) {
    long long v, l, r;
    cin >> v >> l >> r;
    l--;
    v--;
    qq[v].push_back({{l, r}, i});
  }
  dfs(0);
  for (long long i = 0; i < q; i++) cout << ans[i] << "\n";
  return 0;
}
