#include <bits/stdc++.h>
using namespace std;
const long long md = 1e9 + 7;
const int xn = 5e5 + 10;
const int xm = 5e5 + 10;
const int SQ = 500;
const int sq = 7e2 + 10;
const long long inf = 1e18 + 10;
long long a[xn], b[xn], w[xn], ans[xn], dis[xn], c[xn], d;
int n, p[xn], q, r[xn], deg[xn];
vector<pair<pair<int, int>, int> > que[xn];
vector<int> adj[xn];
long long get(int l, int r) {
  long long mn = inf;
  for (int i = l; i <= r;) {
    if (i % SQ == 0 && i + SQ - 1 <= r) {
      mn = min(mn, b[i / SQ] + c[i / SQ]);
      i += SQ;
    } else {
      if (!deg[i]) mn = min(mn, a[i] + c[i / SQ]);
      i++;
    }
  }
  return mn;
}
void update(int l, int r, long long x) {
  for (int i = l; i <= r;) {
    if (i % SQ == 0 && i + SQ - 1 <= r) {
      c[i / SQ] += x;
      i += SQ;
    } else {
      b[i / SQ] = inf;
      for (int j = i - i % SQ; j <= i - i % SQ + SQ - 1; j++) {
        if (deg[j]) continue;
        a[j] += c[i / SQ];
        if (j >= l && j <= r) a[j] += x;
        b[i / SQ] = min(b[i / SQ], a[j]);
      }
      c[i / SQ] = 0;
      i = i - i % SQ + SQ;
    }
  }
}
void DFS2(int v) {
  d += w[v];
  update(v, r[v], -2 * w[v]);
  for (int i = 0; i < que[v].size(); i++) {
    ans[que[v][i].second] =
        get(que[v][i].first.first, que[v][i].first.second) + d;
  }
  for (int i = 0; i < adj[v].size(); i++) {
    int u = adj[v][i];
    DFS2(u);
    d -= w[u];
    update(u, r[u], 2 * w[u]);
  }
}
void DFS(int v) {
  if (v != 1) a[v] = dis[v] = dis[p[v]] + w[v];
  r[v] = v;
  for (int i = 0; i < adj[v].size(); i++) {
    int u = adj[v][i];
    DFS(u);
    r[v] = r[u];
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> q;
  for (int i = 2; i <= n; i++)
    cin >> p[i] >> w[i], deg[p[i]]++, adj[p[i]].push_back(i);
  int ind = 0;
  for (int i = 0; i < q; i++) {
    long long v, l, r;
    cin >> v >> l >> r;
    que[v].push_back({{l, r}, ind});
    ind++;
  }
  DFS(1);
  DFS2(1);
  for (int i = 0; i <= n; i++) b[i] = inf;
  for (int i = 1; i <= n; i++) {
    if (deg[i]) continue;
    b[i / SQ] = min(b[i / SQ], dis[i]);
  }
  for (int i = 0; i < q; i++) cout << ans[i] << '\n';
  return 0;
}
