#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
void ckmin(T &a, U b) {
  if (a > b) a = b;
}
template <class T, class U>
void ckmax(T &a, U b) {
  if (a < b) a = b;
}
int N, Q;
vector<int> edge[530013];
int parent[530013], ft[530013];
long long dup[530013], depth[530013];
vector<pair<pair<int, int>, int> > queries[530013];
long long ans[530013];
long long lazy[2 * 530013], seg[2 * 530013];
void build(int w, int L, int R) {
  if (L == R) {
    seg[w] = (edge[L].empty() ? depth[L] : 2696969696969696969);
    return;
  }
  int mid = (L + R) >> 1;
  build(w << 1, L, mid);
  build(w << 1 | 1, mid + 1, R);
  seg[w] = min(seg[w << 1], seg[w << 1 | 1]);
}
void push(int w, int L, int R) {
  seg[w] += lazy[w];
  if (L != R) {
    lazy[w << 1] += lazy[w];
    lazy[w << 1 | 1] += lazy[w];
  }
  lazy[w] = 0;
  return;
}
void update(int w, int L, int R, int a, int b, long long v) {
  push(w, L, R);
  if (b < L || R < a) return;
  if (a <= L && R <= b) {
    lazy[w] += v;
    push(w, L, R);
    return;
  }
  int mid = (L + R) >> 1;
  update(w << 1, L, mid, a, b, v);
  update(w << 1 | 1, mid + 1, R, a, b, v);
  seg[w] = min(seg[w << 1], seg[w << 1 | 1]);
}
long long query(int w, int L, int R, int a, int b) {
  push(w, L, R);
  if (a <= L && R <= b) {
    return seg[w];
  }
  int mid = (L + R) >> 1;
  if (b <= mid) {
    return query(w << 1, L, mid, a, b);
  }
  if (mid < a) {
    return query(w << 1 | 1, mid + 1, R, a, b);
  }
  return min(query(w << 1, L, mid, a, b), query(w << 1 | 1, mid + 1, R, a, b));
}
void dfs(int u) {
  for (int v : edge[u]) {
    update(1, 0, N - 1, 0, N - 1, dup[v]);
    update(1, 0, N - 1, v, ft[v], -2 * dup[v]);
    dfs(v);
    update(1, 0, N - 1, 0, N - 1, -dup[v]);
    update(1, 0, N - 1, v, ft[v], 2 * dup[v]);
  }
  for (auto e : queries[u]) {
    int qid = e.second, lt = e.first.first, rt = e.first.second;
    ans[qid] = query(1, 0, N - 1, lt, rt);
  }
}
int32_t main() {
  cout << fixed << setprecision(12);
  cerr << fixed << setprecision(4);
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> Q;
  for (auto i = (1); i < (N); i++) {
    cin >> parent[i] >> dup[i];
    parent[i]--;
    edge[parent[i]].push_back(i);
    depth[i] = depth[parent[i]] + dup[i];
  }
  for (auto i = (N)-1; i >= (0); i--) {
    ft[i] = i;
    for (int x : edge[i]) {
      ckmax(ft[i], ft[x]);
    }
  }
  for (auto i = (0); i < (Q); i++) {
    int u, l, r;
    cin >> u >> l >> r;
    u--;
    l--;
    r--;
    queries[u].push_back({{l, r}, i});
  }
  build(1, 0, N - 1);
  dfs(0);
  for (auto i = (0); i < (Q); i++) {
    cout << ans[i] << '\n';
  }
  return 0;
}
