#include <bits/stdc++.h>
using namespace std;
const int64_t INF = int64_t(1e18);
class SegmentTree {
 private:
  int n;
  vector<int64_t> t;
  vector<int64_t> p;
  int64_t get(int v, int l, int r) { return t[v] + p[v]; }
  void push(int v, int l, int r) {
    if (p[v] == 0) {
      return;
    }
    p[v * 2 + 1] += p[v];
    p[v * 2 + 2] += p[v];
    t[v] = get(v, l, r);
    p[v] = 0;
  }
  int64_t query(int v, int l, int r, int ql, int qr) {
    if (ql >= qr) {
      return INF;
    }
    if (ql == l && qr == r) {
      return get(v, l, r);
    }
    int m = (l + r) / 2;
    push(v, l, r);
    int64_t vl = query(v * 2 + 1, l, m, ql, min(qr, m));
    int64_t vr = query(v * 2 + 2, m, r, max(ql, m), qr);
    return min(vl, vr);
  }
  void update(int v, int l, int r, int ql, int qr, int64_t x) {
    if (ql >= qr) {
      return;
    }
    if (ql == l && qr == r) {
      p[v] += x;
      return;
    }
    int m = (l + r) / 2;
    push(v, l, r);
    update(v * 2 + 1, l, m, ql, min(qr, m), x);
    update(v * 2 + 2, m, r, max(ql, m), qr, x);
    t[v] = min(get(v * 2 + 1, l, m), get(v * 2 + 2, m, r));
  }

 public:
  SegmentTree(int n) : n(n), t(4 * n), p(4 * n) {}
  int64_t query(int l, int r) { return query(0, 0, n, l, r); }
  void update(int l, int r, int64_t x) { update(0, 0, n, l, r, x); }
};
const int N = int(5e5);
int n, m;
SegmentTree t(N);
vector<pair<int, int>> g[N];
int mn[N], mx[N];
vector<tuple<int, int, int>> q[N];
int64_t ans[N];
vector<int> unzip;
void dfs1(int x) {
  mn[x] = unzip.size();
  if (g[x].empty()) {
    unzip.push_back(x);
    mx[x] = unzip.size();
  }
  for (auto e : g[x]) {
    dfs1(e.first);
    t.update(mn[e.first], mx[e.first], e.second);
    mn[x] = min(mn[x], mn[e.first]);
    mx[x] = max(mx[x], mx[e.first]);
  }
}
int zip(int x) {
  return lower_bound(unzip.begin(), unzip.end(), x) - unzip.begin();
}
void dfs2(int x) {
  for (auto p : q[x]) {
    ans[get<0>(p)] = t.query(zip(get<1>(p)), zip(get<2>(p)));
  }
  for (auto e : g[x]) {
    t.update(0, unzip.size(), e.second);
    t.update(mn[e.first], mx[e.first], -2 * e.second);
    dfs2(e.first);
    t.update(0, unzip.size(), -e.second);
    t.update(mn[e.first], mx[e.first], 2 * e.second);
  }
}
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i < n; i++) {
    int p, w;
    cin >> p >> w;
    p--;
    g[p].emplace_back(i, w);
  }
  dfs1(0);
  for (int i = 0; i < m; i++) {
    int x, l, r;
    cin >> x >> l >> r;
    x--, l--;
    q[x].emplace_back(i, l, r);
  }
  dfs2(0);
  for (int i = 0; i < m; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}
