#include <bits/stdc++.h>
using namespace std;
const long long N = 5e5 + 6;
const long long Log2 = 19;
const long long inf = 1e16;
vector<pair<long long, long long> > g[N];
struct que {
  long long L, R, pos;
};
vector<que> Query[N];
long long n, Q, i, x, y, ans[N], v, d[N], st[4 * N], lazy[4 * N], Timer = 1,
                                                                  pos[N];
pair<long long, long long> reign[N];
bool leaf[N];
void DFS(long long u) {
  reign[u].first = inf;
  pos[u] = Timer;
  Timer++;
  if (g[u].size() == 1 && u != 1) leaf[u] = 1, reign[u] = {pos[u], pos[u]};
  for (auto i : g[u]) {
    if (i.first != 1 && !d[i.first]) {
      d[i.first] = d[u] + i.second;
      DFS(i.first);
      reign[u].first = min(reign[u].first, reign[i.first].first);
      reign[u].second = max(reign[u].second, reign[i.first].second);
    }
  }
}
void pass(long long id) {
  long long t = lazy[id];
  lazy[id] = 0;
  st[id * 2] += t;
  lazy[id * 2] += t;
  st[id * 2 + 1] += t;
  lazy[id * 2 + 1] += t;
}
void upd(long long id, long long l, long long r, long long u, long long v,
         long long val) {
  if (u > v) return;
  if (v < l || r < u) return;
  if (u <= l && r <= v) {
    st[id] += val, lazy[id] += val;
    return;
  }
  long long mid = (l + r) / 2;
  pass(id);
  upd(id * 2, l, mid, u, v, val);
  upd(id * 2 + 1, mid + 1, r, u, v, val);
  st[id] = min(st[id * 2], st[id * 2 + 1]);
}
long long Get(long long id, long long l, long long r, long long u,
              long long v) {
  if (v < l || r < u) return inf;
  if (u <= l && r <= v) return st[id];
  long long mid = (l + r) / 2;
  pass(id);
  return min(Get(id * 2, l, mid, u, v), Get(id * 2 + 1, mid + 1, r, u, v));
}
void Fix(long long L, long long R, long long val) {
  upd(1, 1, n, L, R, -val);
  upd(1, 1, n, 1, L - 1, val);
  upd(1, 1, n, R + 1, n, val);
}
void dfs(long long u) {
  for (auto i : Query[u]) {
    long long L = i.L, R = i.R, p = i.pos;
    ans[p] = Get(1, 1, n, L, R);
  }
  for (auto i : g[u]) {
    if (d[i.first] < d[u]) continue;
    long long L = reign[i.first].first, R = reign[i.first].second;
    Fix(L, R, i.second);
    dfs(i.first);
    Fix(L, R, -i.second);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  if (fopen("tst"
            ".inp",
            "r")) {
    freopen(
        "tst"
        ".inp",
        "r", stdin);
  }
  cin >> n >> Q;
  for (i = 2; i <= n; i++) {
    cin >> x >> y;
    g[i].push_back({x, y});
    g[x].push_back({i, y});
  }
  for (i = 1; i <= Q; i++) {
    cin >> v >> x >> y;
    Query[v].push_back({x, y, i});
  }
  DFS(1);
  for (i = 1; i <= n; i++) {
    if (leaf[i])
      upd(1, 1, n, pos[i], pos[i], d[i]);
    else
      upd(1, 1, n, pos[i], pos[i], inf);
  }
  dfs(1);
  for (i = 1; i <= Q; i++) cout << ans[i] << "\n";
}
