#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500005;
const int MAXD = 20;
int N, Q, trav[MAXN], curr, sz[MAXN], LCA[MAXN][MAXD], depth[MAXN];
vector<pair<int, long long> > adj[MAXN];
long long dist[MAXN], t[4 * MAXN], t2[MAXN];
int getLCA(int a, int b) {
  if (depth[a] < depth[b]) swap(a, b);
  for (int d = MAXD - 1; d >= 0; d--) {
    if (depth[a] - (1 << d) >= depth[b]) {
      a = LCA[a][d];
    }
  }
  for (int d = MAXD - 1; d >= 0; d--) {
    if (LCA[a][d] != LCA[b][d]) {
      a = LCA[a][d];
      b = LCA[b][d];
    }
  }
  if (a != b) a = LCA[a][0];
  return a;
}
void setup(int v, int tl, int tr) {
  if (tl == tr) {
    if (tl != 1 && adj[tl].size() == 1) {
      t[v] = dist[tl];
    } else {
      t[v] = 1e18;
    }
    t2[v] = tl;
  } else {
    int tm = (tl + tr) / 2;
    setup(2 * v, tl, tm);
    setup(2 * v + 1, tm + 1, tr);
    t[v] = min(t[2 * v], t[2 * v + 1]);
    t2[v] = getLCA(t2[2 * v], t2[2 * v + 1]);
  }
}
long long get(int v, int tl, int tr, int l, int r, int s) {
  if (l > r) return 1e18;
  if (tl == l && tr == r) {
    if (trav[s] + sz[s] - 1 < l || trav[s] > r) {
      int tlca = getLCA(s, t2[v]);
      return t[v] - 2 * dist[tlca] + dist[s];
    } else if (trav[s] <= l && trav[s] + sz[s] - 1 >= r) {
      return t[v] - dist[s];
    } else {
      long long a =
          get(v, tl, tr, max(trav[s], l), min(trav[s] + sz[s] - 1, r), s);
      long long b = get(v, tl, tr, l, min(trav[s] - 1, r), s);
      long long c = get(v, tl, tr, max(trav[s] + sz[s], l), r, s);
      return min(a, min(b, c));
    }
  }
  int tm = (tl + tr) / 2;
  return min(get(2 * v, tl, tm, l, min(r, tm), s),
             get(2 * v + 1, tm + 1, tr, max(tm + 1, l), r, s));
}
void initLCA() {
  for (int d = 1; d < MAXD; d++) {
    for (int i = 1; i <= N; i++) {
      LCA[i][d] = LCA[LCA[i][d - 1]][d - 1];
    }
  }
}
void dfs(int v, int p) {
  sz[v]++;
  trav[v] = ++curr;
  for (auto it : adj[v])
    if (it.first != p) {
      dist[it.first] = dist[v] + it.second;
      depth[it.first] = depth[v] + 1;
      LCA[it.first][0] = v;
      dfs(it.first, v);
      sz[v] += sz[it.first];
    }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> N >> Q;
  for (int i = 2; i <= N; i++) {
    int p;
    long long w;
    cin >> p >> w;
    adj[i].push_back(make_pair(p, w));
    adj[p].push_back(make_pair(i, w));
  }
  for (int i = 1; i <= N; i++) {
    sort(adj[i].begin(), adj[i].end());
  }
  dfs(1, 0);
  initLCA();
  setup(1, 1, N);
  for (int i = 0; i < Q; i++) {
    int v, l, r;
    cin >> v >> l >> r;
    cout << get(1, 1, N, l, r, v) << "\n";
  }
}
