#include <bits/stdc++.h>
using namespace std;
const long long inf = 2e18 + 5;
const int N = 500005;
long long t[N * 4], need[N];
inline void lazy(int v, bool err) {
  if (need[v]) {
    t[v] += need[v];
    if (err) {
      need[v] = 0;
      return;
    }
    need[v * 2] += need[v];
    need[v * 2 + 1] += need[v];
    need[v] = 0;
  }
}
void update(int v, int tl, int tr, int l, int r, long long val) {
  lazy(v, (tl == tr));
  if (l > r) return;
  if (tl == l && tr == r) {
    need[v] += val;
    lazy(v, (tl == tr));
    return;
  }
  int tm = (tl + tr) >> 1;
  update(v * 2, tl, tm, l, min(tm, r), val);
  update(v * 2 + 1, tm + 1, tr, max(tm + 1, l), r, val);
  t[v] = min(t[v * 2], t[v * 2 + 1]);
}
long long solve(int v, int tl, int tr, int l, int r) {
  if (l > r) return inf;
  lazy(v, (tl == tr));
  if (tl == l && tr == r) {
    return t[v];
  }
  int tm = (tl + tr) >> 1;
  long long a = solve(v * 2, tl, tm, l, min(tm, r));
  long long b = solve(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
  return min(a, b);
}
long long sz[N], len[N], sol[N], n;
vector<pair<pair<long long, int>, int> > que[N];
vector<pair<long long, int> > g[N];
void dfs(int v, int p, long long di) {
  sz[v] = 1;
  len[v] = di;
  if (g[v].size() == 1 && g[v][0].first == p)
    update(1, 0, n - 1, v, v, -inf + len[v]);
  for (auto to : g[v])
    if (to.first != p) {
      dfs(to.first, v, to.second + di);
      sz[v] += sz[to.first];
    }
}
void ans(int v, int p = -1) {
  for (auto to : que[v]) {
    sol[to.second] = solve(1, 0, n - 1, to.first.first, to.first.second);
  }
  for (auto to : g[v])
    if (to.first != p) {
      update(1, 0, n - 1, 0, n - 1, to.second);
      update(1, 0, n - 1, to.first, to.first + sz[to.first] - 1,
             -2 * to.second);
      ans(to.first, v);
      update(1, 0, n - 1, to.first, to.first + sz[to.first] - 1, 2 * to.second);
      update(1, 0, n - 1, 0, n - 1, -to.second);
    }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> n >> q;
  fill(t, t + n * 4, inf);
  for (int i = 1; i < n; ++i) {
    int p, co;
    cin >> p >> co;
    --p;
    g[i].push_back({p, co});
    g[p].push_back({i, co});
  }
  for (int now = 0; now < q; ++now) {
    int v, l, r;
    cin >> v >> l >> r;
    --v, --l, --r;
    que[v].push_back({{l, r}, now});
  }
  dfs(0, 0, 0);
  ans(0);
  for (int i = 0; i < q; ++i) cout << sol[i] << '\n';
}
