#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
vector<pair<int, int> > g[N];
long long tree[N << 2], ans[N], lazy[N << 2];
void propagate(int i, int l, int r) {
  if (!lazy[i]) return;
  tree[i] += lazy[i];
  if (l != r) lazy[i << 1] += lazy[i], lazy[i << 1 | 1] += lazy[i];
  lazy[i] = 0;
}
long long get(int i, int l, int r, int a, int b) {
  propagate(i, l, r);
  if (l > b || r < a) return 1e16;
  if (l >= a && r <= b) return tree[i];
  int mid = (l + r) >> 1;
  return min(get(i << 1, l, mid, a, b), get(i << 1 | 1, mid + 1, r, a, b));
}
void update(int i, int l, int r, int a, int b, int v, bool f) {
  propagate(i, l, r);
  if (l > b || r < a) return;
  if (l >= a && r <= b) {
    lazy[i] += v;
    propagate(i, l, r);
    if (f) tree[i] = 0;
    return;
  }
  int mid = (l + r) >> 1;
  update(i << 1, l, mid, a, b, v, f);
  update(i << 1 | 1, mid + 1, r, a, b, v, f);
  tree[i] = min(tree[i << 1], tree[i << 1 | 1]);
}
int n;
int sz[N];
void pre(int node) {
  int &ret = sz[node] = 1;
  for (int i = 0; i < g[node].size(); i++) {
    int v = g[node][i].first;
    pre(v);
    ret += sz[v];
  }
}
vector<pair<int, pair<int, int> > > qr[N];
void dfs(int node) {
  sort(g[node].begin(), g[node].end());
  if (!g[node].size()) update(1, 1, n, node, node, 0, 1);
  for (int i = 0; i < g[node].size(); i++) {
    int v = g[node][i].first;
    int w = g[node][i].second;
    update(1, 1, n, 1, v - 1, w, 0);
    dfs(v);
    update(1, 1, n, 1, v - 1, -w, 0);
    update(1, 1, n, v, v + sz[v] - 1, w, 0);
  }
  for (int i = 0; i < qr[node].size(); i++) {
    int l = qr[node][i].second.first;
    int r = qr[node][i].second.second;
    ans[qr[node][i].first] = get(1, 1, n, l, r);
  }
}
void rvd(int node) {
  sort(g[node].rbegin(), g[node].rend());
  if (!g[node].size()) update(1, 1, n, node, node, 0, 1);
  for (int i = 0; i < g[node].size(); i++) {
    int v = g[node][i].first;
    int w = g[node][i].second;
    if (v + sz[v] != n) update(1, 1, n, v + sz[v], n, w, 0);
    rvd(v);
    if (v + sz[v] != n) update(1, 1, n, v + sz[v], n, -w, 0);
    update(1, 1, n, v, v + sz[v] - 1, w, 0);
  }
  for (int i = 0; i < qr[node].size(); i++) {
    int l = qr[node][i].second.first;
    int r = qr[node][i].second.second;
    ans[qr[node][i].first] = min(ans[qr[node][i].first], get(1, 1, n, l, r));
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int q;
  cin >> n >> q;
  for (int i = 2, p, w; i <= n; i++) {
    cin >> p >> w;
    g[p].push_back(make_pair(i, w));
  }
  for (int i = 0, v, l, r; i < q; i++) {
    cin >> v >> l >> r;
    qr[v].push_back(make_pair(i, make_pair(l, r)));
  }
  for (int i = 0; i < N * 4; i++) tree[i] = 1e16;
  pre(1);
  dfs(1);
  for (int i = 0; i < N * 4; i++) tree[i] = 1e16, lazy[i] = 0;
  rvd(1);
  for (int i = 0; i < q; i++) cout << ans[i] << '\n';
  return 0;
}
