#include <bits/stdc++.h>
using namespace std;
const int NMAX = 5e5 + 7;
const long long INF = 5e18;
struct segTree {
  long long t[4 * NMAX], lazy[4 * NMAX];
  void _init() {
    for (int i = 0; i < 4 * NMAX; i++) t[i] = INF;
  }
  void push_down(int node, int l, int r) {
    if (lazy[node]) {
      t[node] += lazy[node];
      if (l < r) {
        lazy[2 * node] += lazy[node];
        lazy[2 * node + 1] += lazy[node];
      }
      lazy[node] = 0;
    }
  }
  void update(int node, int st, int en, int l, int r, long long val) {
    push_down(node, st, en);
    if (st > en || st > r || l > en) return;
    if (l <= st && en <= r) {
      lazy[node] += val;
      push_down(node, st, en);
      return;
    }
    int mid = (st + en) / 2;
    update(2 * node, st, mid, l, r, val);
    update(2 * node + 1, mid + 1, en, l, r, val);
    t[node] = min(t[2 * node], t[2 * node + 1]);
  }
  long long get(int node, int st, int en, int l, int r) {
    push_down(node, st, en);
    if (st > en || st > r || l > en) return INF;
    if (l <= st && en <= r) return t[node];
    int mid = (st + en) / 2;
    long long t1 = get(2 * node, st, mid, l, r);
    long long t2 = get(2 * node + 1, mid + 1, en, l, r);
    return min(t1, t2);
  }
} T;
int n, Q;
long long ans[NMAX];
vector<pair<int, long long> > g[NMAX];
vector<pair<pair<int, int>, int> > v[NMAX];
long long sz[NMAX], dep[NMAX];
int Time = 0;
int tin[NMAX], tout[NMAX];
void dfs1(int son, int par, long long dub) {
  tin[son] = ++Time;
  dep[son] = dub;
  sz[son] = 1;
  for (pair<int, int> it : g[son]) {
    if (it.first == par) continue;
    dfs1(it.first, son, dub + it.second);
    sz[son] += sz[it.first];
  }
  tout[son] = Time;
}
void resi(int son, int par) {
  for (pair<pair<int, int>, int> it : v[son])
    ans[it.second] = T.get(1, 1, n, it.first.first, it.first.second);
  for (pair<int, int> it : g[son]) {
    if (it.first == par) continue;
    long long val = it.second;
    int nxt = it.first;
    T.update(1, 1, n, 1, n, val);
    T.update(1, 1, n, tin[nxt], tout[nxt], -2LL * val);
    resi(nxt, son);
    T.update(1, 1, n, 1, n, -val);
    T.update(1, 1, n, tin[nxt], tout[nxt], +2LL * val);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> Q;
  for (int i = 2; i <= n; i++) {
    int p;
    long long w;
    cin >> p >> w;
    g[i].push_back({p, w});
    g[p].push_back({i, w});
  }
  T._init();
  for (int i = 1; i <= Q; i++) {
    int v1, l, r;
    cin >> v1 >> l >> r;
    v[v1].push_back({{l, r}, i});
  }
  dfs1(1, 0, 0);
  for (int i = 2; i <= n; i++)
    if (sz[i] == 1) T.update(1, 1, n, i, i, dep[i] - INF);
  resi(1, 0);
  for (int i = 1; i <= Q; i++) cout << ans[i] << endl;
  return 0;
}
