#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <typename T>
using vec = std::vector<T>;
template <typename T>
using uset = std::unordered_set<T>;
template <typename T1, typename T2>
using umap = std::unordered_map<T1, T2>;
constexpr ll INFL = 1000000000000000069;
constexpr ll INFI = 1000000069;
const ld PI = acos(-1);
std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());
vec<pair<ll, ll>> DD = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
const ll N = 5e5 + 10;
vec<pair<ll, ll>> g[N];
ll n;
ll dist[N];
ll tin[N], tout[N];
ll dfs_timer = 0;
void calc_dist(ll u) {
  tin[u] = dfs_timer++;
  for (auto [v, len] : g[u]) {
    dist[v] = dist[u] + len;
    calc_dist(v);
  }
  if (!g[u].empty()) dist[u] = INFL;
  tout[u] = dfs_timer;
}
namespace seg_tree {
ll t[N * 4], agn[N * 4];
void build(ll v, ll l, ll r) {
  if (r - l == 1) {
    t[v] = dist[l];
    agn[v] = 0;
  } else {
    ll mid = (l + r) / 2;
    build(v * 2 + 1, l, mid);
    build(v * 2 + 2, mid, r);
    t[v] = min(t[v * 2 + 1], t[v * 2 + 2]);
    agn[v] = 0;
  }
}
void push(ll v, ll l, ll r) {
  t[v] += agn[v];
  if (r - l > 1) {
    agn[v * 2 + 1] += agn[v];
    agn[v * 2 + 2] += agn[v];
  }
  agn[v] = 0;
}
void modify(ll v, ll l, ll r, ll lq, ll rq, ll x) {
  push(v, l, r);
  if (lq <= l && r <= rq) {
    agn[v] += x;
    push(v, l, r);
  } else if (rq <= l || r <= lq) {
    return;
  } else {
    ll mid = (l + r) / 2;
    modify(v * 2 + 1, l, mid, lq, rq, x);
    modify(v * 2 + 2, mid, r, lq, rq, x);
    t[v] = min(t[v * 2 + 1], t[v * 2 + 2]);
  }
}
ll get(ll v, ll l, ll r, ll lq, ll rq) {
  push(v, l, r);
  if (lq <= l && r <= rq) {
    return t[v];
  } else if (rq <= l || r <= lq) {
    return INFL;
  } else {
    ll ans = INFL;
    ll mid = (l + r) / 2;
    ans = min(ans, get(v * 2 + 1, l, mid, lq, rq));
    ans = min(ans, get(v * 2 + 2, mid, r, lq, rq));
    return ans;
  }
}
void print(ll v, ll l, ll r) {
  push(v, l, r);
  if (r - l == 1) {
    cerr << t[v] << ' ';
  } else {
    ll mid = (l + r) / 2;
    print(v * 2 + 1, l, mid);
    print(v * 2 + 2, mid, r);
  }
}
}  // namespace seg_tree
vec<tuple<ll, ll, ll>> queries[N];
ll ans[N];
void dfs(ll u) {
  for (auto [l, r, i] : queries[u]) {
    ans[i] = seg_tree::get(0, 0, n, l - 1, r);
  }
  for (auto [v, w] : g[u]) {
    seg_tree::modify(0, 0, n, 0, tin[v], w);
    seg_tree::modify(0, 0, n, tin[v], tout[v], -w);
    seg_tree::modify(0, 0, n, tout[v], dfs_timer, w);
    dfs(v);
    seg_tree::modify(0, 0, n, 0, tin[v], -w);
    seg_tree::modify(0, 0, n, tin[v], tout[v], w);
    seg_tree::modify(0, 0, n, tout[v], dfs_timer, -w);
  }
}
void run() {
  ll q;
  cin >> n >> q;
  for (ll i = 1; i < n; i++) {
    ll anc, len;
    cin >> anc >> len;
    g[anc - 1].emplace_back(i, len);
  }
  calc_dist(0);
  seg_tree::build(0, 0, n);
  for (ll i = 0; i < q; i++) {
    ll v, l, r;
    cin >> v >> l >> r;
    v--;
    queries[v].emplace_back(l, r, i);
  }
  dfs(0);
  for (ll i = 0; i < q; i++) {
    cout << ans[i] << '\n';
  }
}
signed main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll t = 1;
  while (t--) {
    run();
  }
  return 0;
}
