#include <bits/stdc++.h>
using namespace std;
struct hoba {
  int l, r, q;
  hoba(int L, int R, int Q) {
    l = L;
    r = R;
    q = Q;
  }
};
const int N = 5e5 + 5;
long long tree[4 * N], cost[N], lazy[4 * N];
int n, q, in[N], out[N], id;
int change[4 * N];
vector<pair<int, int> > node[N];
vector<hoba> range[N];
long long res[N];
void propagate(int curr, int st, int en) {
  if (!lazy[curr]) return;
  tree[curr] += lazy[curr];
  if (st != en) lazy[2 * curr] += lazy[curr], lazy[2 * curr + 1] += lazy[curr];
  lazy[curr] = 0;
}
void update2(int curr, int st, int en, int shemal, int yemeen, long long val) {
  propagate(curr, st, en);
  if (st > en || st > yemeen || en < shemal || shemal > yemeen) return;
  if (shemal <= st && en <= yemeen) {
    lazy[curr] += val;
    propagate(curr, st, en);
    return;
  }
  int mid = (st + en) / 2;
  update2(2 * curr, st, mid, shemal, yemeen, val);
  update2(2 * curr + 1, mid + 1, en, shemal, yemeen, val);
  tree[curr] = min(tree[2 * curr], tree[2 * curr + 1]);
}
void update1(int curr, int st, int en, int shemal, int yemeen, long long val) {
  if (st > en || st > yemeen || en < shemal || shemal > yemeen) return;
  if (shemal <= st && en <= yemeen) {
    if (tree[curr] == 1e15) tree[curr] = 0;
    tree[curr] += val;
    return;
  }
  int mid = (st + en) / 2;
  update1(2 * curr, st, mid, shemal, yemeen, val);
  update1(2 * curr + 1, mid + 1, en, shemal, yemeen, val);
  tree[curr] = min(tree[2 * curr], tree[2 * curr + 1]);
}
long long query(int curr, int st, int en, int shemal, int yemeen) {
  propagate(curr, st, en);
  if (st > en || st > yemeen || en < shemal || shemal > yemeen)
    return LLONG_MAX;
  if (shemal <= st && en <= yemeen) return tree[curr];
  int mid = (st + en) / 2;
  long long a = query(2 * curr, st, mid, shemal, yemeen);
  long long b = query(2 * curr + 1, mid + 1, en, shemal, yemeen);
  return min(a, b);
}
void dfs(int v, int p) {
  in[v] = ++id;
  for (auto i : node[v]) {
    if (i.first == p) continue;
    cost[i.first] = cost[v] + 1ll * i.second;
    dfs(i.first, v);
  }
  out[v] = id;
}
void dfs2(int v, int p) {
  for (auto x : range[v]) {
    int l = x.l, r = x.r, idx = x.q;
    res[idx] = query(1, 0, id, l, r);
  }
  for (auto i : node[v]) {
    if (i.first == p) continue;
    int idx = i.first;
    long long val = i.second;
    update2(1, 0, id, 1, id, val);
    update2(1, 0, id, in[idx], out[idx], -2ll * val);
    dfs2(idx, v);
    update2(1, 0, id, 1, id, -val);
    update2(1, 0, id, in[idx], out[idx], 2ll * val);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  for (auto i = 0; i < (long long)(4 * N); i++) tree[i] = 1e15;
  cin >> n >> q;
  for (auto i = 2; i <= (long long)(n); i++) {
    int p, v;
    cin >> p >> v;
    node[p].push_back({i, v});
    node[i].push_back({p, v});
  }
  for (auto i = 1; i <= (long long)(n); i++) {
    sort(((node[i]).begin()), ((node[i]).end()));
  }
  dfs(1, 0);
  for (auto i = 1; i <= (long long)(n); i++)
    if (((int)((node[i]).size())) == 1)
      update1(1, 0, id, in[i], in[i], cost[i]);
  for (auto i = 1; i <= (long long)(q); i++) {
    int x, l, r;
    cin >> x >> l >> r;
    hoba curr(l, r, i);
    range[x].push_back(curr);
  }
  dfs2(1, 0);
  for (auto i = 1; i <= (long long)(q); i++) cout << res[i] << '\n';
  return 0;
}
