#include <bits/stdc++.h>
using namespace std;
template <typename T>
using V = vector<T>;
template <class T>
struct SegTree {
  static const int LOGN = 20;
  int n;
  vector<T> sz, lz, st;
  SegTree(int n) {
    this->n = n;
    sz.resize(2 * n, 1), st.resize(2 * n, 0), lz.resize(n);
    for (int i = n - 1; i > 0; i--) {
      sz[i] = sz[i << 1] + sz[i << 1 | 1];
      st[i] = min(st[i << 1], st[i << 1 | 1]);
    }
  }
  void apply(int p, T val) {
    st[p] += val;
    if (p < n) lz[p] += val;
  }
  void pushup(int p) {
    while (p > 1) p >>= 1, st[p] = min(st[p << 1], st[p << 1 | 1]) + lz[p];
  }
  void pushdown(int p) {
    for (int i = LOGN; i > 0; i--) {
      int q = p >> i;
      if (lz[q]) {
        apply(q << 1, lz[q]);
        apply(q << 1 | 1, lz[q]);
        lz[q] = 0;
      }
    }
  }
  void upd(int l, int r, T val) {
    l += n, r += n + 1;
    int l0 = l, r0 = r;
    for (; l < r; l >>= 1, r >>= 1) {
      if (l & 1) apply(l++, val);
      if (r & 1) apply(--r, val);
    }
    pushup(l0);
    pushup(r0 - 1);
  }
  T query(int l, int r) {
    l += n, r += n + 1;
    pushdown(l), pushdown(r - 1);
    T res = 1e17;
    for (; l < r; l >>= 1, r >>= 1) {
      if (l & 1) res = min(res, st[l++]);
      if (r & 1) res = min(res, st[--r]);
    }
    return res;
  }
};
vector<vector<pair<int, int> > > T;
vector<long long> d;
vector<int> in, out;
int t = 0;
void dfs(int u, long long dis) {
  in[u] = t;
  if (T[u].empty()) {
    d[in[u]] = dis;
  }
  t++;
  for (auto v : T[u]) {
    dfs(v.first, dis + v.second);
  }
  out[u] = t - 1;
}
struct query {
  int lt, rt, ind;
  long long ans;
  query(int l, int r, int _it) { lt = l, rt = r, ind = _it; }
};
vector<vector<query> > Q;
int n;
long long g = 0;
void dfs2(int u, SegTree<long long> &seg) {
  for (auto &q : Q[u]) {
    q.ans = g + seg.query(q.lt, q.rt);
  }
  for (auto v : T[u]) {
    g += v.second;
    seg.upd(in[v.first], out[v.first], -2 * v.second);
    dfs2(v.first, seg);
    seg.upd(in[v.first], out[v.first], +2 * v.second);
    g -= v.second;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> n >> q;
  SegTree<long long> seg(n);
  in.resize(n), out.resize(n), d.resize(n, 1e17), T.resize(n);
  for (int i = 0; i < n - 1; i++) {
    int u, w;
    cin >> u >> w;
    T[u - 1].push_back({i + 1, w});
  }
  dfs(0, 0);
  Q.resize(n);
  for (int i = 0; i < n; i++) {
    seg.upd(in[i], in[i], d[in[i]]);
  }
  for (int i = 0; i < q; i++) {
    int l, r, v;
    cin >> v >> l >> r;
    l--;
    r--;
    v--;
    Q[v].push_back(query(l, r, i));
  }
  dfs2(0, seg);
  vector<long long> A(q);
  for (int i = 0; i < n; i++) {
    for (auto &qu : Q[i]) {
      A[qu.ind] = qu.ans;
    }
  }
  for (int i = 0; i < q; i++) {
    cout << A[i] << endl;
  }
  return 0;
}
