#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 100;
const long long inf = 1e15 + 7;
int n, q, idx;
int id[N], en[N];
long long ans[N];
long long MIN[4 * N], t[4 * N], depth[4 * N];
vector<int> qu[N];
pair<int, int> range[N];
vector<pair<int, int>> g[N];
void dfs(int u, int prv = 0) {
  id[u] = ++idx;
  for (auto ss : g[u])
    if (ss.first != prv) {
      depth[ss.first] = depth[u] + ss.second;
      dfs(ss.first, u);
    }
  en[u] = idx;
}
void lazy(int x) {
  MIN[x] += t[x];
  t[2 * x] += t[x];
  t[2 * x + 1] += t[x];
  t[x] = 0;
}
void update(int x, int l, int r, int i, int j, long long val) {
  if (l > j || r < i) return;
  if (i <= l && r <= j) {
    t[x] += val;
    lazy(x);
    return;
  }
  lazy(x);
  int mid = l + r >> 1;
  update(2 * x, l, mid, i, j, val);
  update(2 * x + 1, mid + 1, r, i, j, val);
  MIN[x] = min(MIN[2 * x], MIN[2 * x + 1]);
}
long long query(int x, int l, int r, int i, int j) {
  if (l > j || r < i) return inf;
  lazy(x);
  if (i <= l && r <= j) return MIN[x];
  int mid = l + r >> 1;
  return min(query(2 * x, l, mid, i, j), query(2 * x + 1, mid + 1, r, i, j));
}
inline void up(int x, int y, int val) {
  update(1, 1, n, x, y, -val);
  update(1, 1, n, 1, x - 1, val);
  update(1, 1, n, y + 1, n, val);
}
void go(int u, int prv = 0) {
  for (auto idQ : qu[u]) {
    int l = range[idQ].first, r = range[idQ].second;
    ans[idQ] = query(1, 1, n, l, r);
  }
  for (auto ss : g[u])
    if (ss.first != prv) {
      up(id[ss.first], en[ss.first], ss.second);
      go(ss.first, u);
      up(id[ss.first], en[ss.first], -ss.second);
    }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  for (int i = 2, p, w; i <= n; ++i) {
    cin >> p >> w;
    g[p].push_back({i, w});
  }
  idx = 0;
  dfs(1);
  for (int i = 1; i <= n; ++i) {
    update(1, 1, n, id[i], id[i], (g[i].empty() ? depth[i] : inf));
  }
  for (int vi, li, ri, i = 1; i <= q; ++i) {
    cin >> vi >> li >> ri;
    range[i] = {li, ri};
    qu[vi].push_back(i);
  }
  go(1);
  for (int i = 1; i <= q; ++i) cout << ans[i] << '\n';
}
