#include <bits/stdc++.h>
using namespace std;
const long long MOD = (1e9) + 7;
const long double EPS = 0.0000001;
const int N = 500000 + 50;
const long long INF = 1e18;
vector<pair<long long, long long> > graph[N];
long long weight[N];
long long st[N];
long long ed[N];
int timer = 0;
long long ans[N];
pair<long long, long long> tree[4 * N];
long long lazy[4 * N];
vector<pair<int, pair<long long, long long> > > queries[N];
int n;
pair<long long, long long> combine(pair<long long, long long> a,
                                   pair<long long, long long> b) {
  pair<long long, long long> temp = {0, 0};
  temp.first = a.first + b.first;
  temp.second = min(a.second, b.second);
  return temp;
}
inline void propagate(int node, long long l, long long r) {
  if (lazy[node] != 0) {
    tree[node].first = (r - l + 1) * lazy[node];
    tree[node].second += lazy[node];
    if (l != r) {
      lazy[2 * node] += lazy[node];
      lazy[2 * node + 1] += lazy[node];
    }
    lazy[node] = 0;
  }
}
void updatePt(int node, int l, int r, int idx, long long val) {
  if (l > r || l > idx || r < idx) return;
  if (l == r) {
    tree[node].first = val;
    tree[node].second = val;
    return;
  }
  int mid = (l + r) / 2;
  updatePt(2 * node, l, mid, idx, val);
  updatePt(2 * node + 1, mid + 1, r, idx, val);
  tree[node] = combine(tree[2 * node], tree[node + node + 1]);
}
void update(int node, long long l, long long r, int a, int b, long long val) {
  propagate(node, l, r);
  if (l > b || r < a || l > r || a > b) return;
  if (a <= l && r <= b) {
    tree[node].first += (r - l + 1) * val;
    tree[node].second += val;
    if (l != r) {
      lazy[2 * node] += val;
      lazy[2 * node + 1] += val;
    }
    return;
  }
  int mid = (l + r) / 2;
  update(node + node, l, mid, a, b, val);
  update(node + node + 1, mid + 1, r, a, b, val);
  tree[node] = combine(tree[2 * node], tree[2 * node + 1]);
}
pair<long long, long long> ask(int node, int l, int r, int a, int b) {
  propagate(node, l, r);
  if (l > b || r < a || l > r || a > b) return {0, INF};
  if (a <= l && r <= b) return tree[node];
  int mid = (l + r) / 2;
  return combine(ask(2 * node, l, mid, a, b),
                 ask(2 * node + 1, mid + 1, r, a, b));
}
void dfs(int node, int pa) {
  st[node] = ++timer;
  for (auto it : graph[node]) {
    if (it.first == pa) continue;
    weight[it.first] = weight[node] + it.second;
    dfs(it.first, node);
  }
  ed[node] = timer;
}
void solve(int node, int pa, long long w) {
  if (node != 1) {
    update(1, 1, n, st[node], ed[node], -2 * w);
    update(1, 1, n, 1, timer, w);
  }
  for (auto it : queries[node]) {
    int who = it.first;
    int l = it.second.first;
    int r = it.second.second;
    ans[who] = ask(1, 1, n, l, r).second;
  }
  for (auto it : graph[node]) {
    if (it.first == pa) continue;
    solve(it.first, node, it.second);
  }
  if (node != 1) {
    update(1, 1, n, st[node], ed[node], 2 * w);
    update(1, 1, n, 1, timer, -w);
  }
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int q;
  cin >> n >> q;
  for (int i = 2; i <= n; i++) {
    long long p, x;
    cin >> p >> x;
    graph[p].push_back({i, x});
    graph[i].push_back({p, x});
  }
  for (int i = 0; i < 4 * N; i++) tree[i].second = INF;
  dfs(1, 0);
  for (int i = 2; i <= n; i++) {
    if (graph[i].size() == 1) {
      updatePt(1, 1, n, st[i], weight[i]);
    }
  }
  for (int i = 0; i < q; i++) {
    int v, l, r;
    cin >> v >> l >> r;
    queries[v].push_back(make_pair(i, make_pair(l, r)));
  }
  solve(1, 0, 0);
  for (int i = 0; i < q; i++) cout << ans[i] << endl;
  return 0;
}
