#include <bits/stdc++.h>
using namespace std;
const long long INF = (1ll) << 62;
vector<pair<int, int> > adj[505050];
int deg[505050];
bool chk[505050];
int up[505050];
int sz[505050];
vector<int> lf[505050];
long long T[4 * 10101010];
int st[505050];
int sp[20][505050];
long long sm[20][505050];
int dep[505050];
int N, Q;
int id = 1;
vector<int> tmp;
void update(int idx, int s, int e, int p, long long x) {
  if (e < s || p < s || e < p) return;
  if (s == e) {
    T[idx] = x;
    return;
  }
  int m = s + e >> 1;
  update(idx * 2, s, m, p, x);
  update(idx * 2 + 1, m + 1, e, p, x);
  T[idx] = min(T[idx * 2], T[idx * 2 + 1]);
}
long long get(int idx, int s, int e, int p, int q) {
  if (e < s || q < p || q < s || e < p) return INF;
  if (p <= s && e <= q) return T[idx];
  int m = s + e >> 1;
  return min(get(idx * 2, s, m, p, q), get(idx * 2 + 1, m + 1, e, p, q));
}
void init(int now, int par) {
  dep[now] = dep[par] + 1;
  sp[0][now] = par;
  for (pair<int, int> i : adj[now]) {
    if (i.first == par) continue;
    sm[0][i.first] = i.second;
    init(i.first, now);
  }
}
int lca(int a, int b) {
  if (dep[a] < dep[b]) return lca(b, a);
  for (int i = 19; i >= 0; i--) {
    if (dep[sp[i][a]] < dep[b]) continue;
    a = sp[i][a];
  }
  if (a == b) return a;
  for (int i = 19; i >= 0; i--) {
    if (sp[i][a] == sp[i][b]) continue;
    a = sp[i][a];
    b = sp[i][b];
  }
  return sp[0][a];
}
long long dist(int a, int b) {
  int l = lca(a, b);
  long long ret = 0;
  for (int i = 19; i >= 0; i--) {
    if (dep[sp[i][a]] < dep[l]) continue;
    ret += sm[i][a];
    a = sp[i][a];
  }
  for (int i = 19; i >= 0; i--) {
    if (dep[sp[i][b]] < dep[l]) continue;
    ret += sm[i][b];
    b = sp[i][b];
  }
  return ret;
}
void dfs(int now, int par) {
  sz[now] = 1;
  if (deg[now] == 1) tmp.push_back(now);
  for (auto i : adj[now]) {
    if (i.first == par) continue;
    if (chk[i.first]) continue;
    dfs(i.first, now);
    sz[now] += sz[i.first];
  }
}
void solve(int now) {
  dfs(now, 0);
  int cen = now, bef = 0;
  while (1) {
    bool fg = false;
    for (auto i : adj[cen]) {
      if (i.first == bef) continue;
      if (chk[i.first]) continue;
      if (sz[i.first] * 2 > sz[now]) {
        fg = true;
        bef = cen;
        cen = i.first;
        break;
      }
    }
    if (!fg) break;
  }
  while (tmp.size()) {
    lf[cen].push_back(tmp.back());
    tmp.pop_back();
  }
  sort(lf[cen].begin(), lf[cen].end());
  st[cen] = id;
  for (int i : lf[cen]) {
    update(1, 1, 10000000, id, dist(cen, i));
    id++;
  }
  chk[cen] = true;
  for (auto i : adj[cen]) {
    if (chk[i.first]) continue;
    up[i.first] = cen;
    solve(i.first);
  }
}
long long query(int v, int l, int r) {
  auto itl = lower_bound(lf[v].begin(), lf[v].end(), l);
  if (itl == lf[v].end()) return INF;
  auto itr = upper_bound(lf[v].begin(), lf[v].end(), r);
  if (itr == lf[v].begin()) return INF;
  itr--;
  return get(1, 1, 10000000, st[v] + (itl - lf[v].begin()),
             st[v] + (itr - lf[v].begin()));
}
int main() {
  for (int i = 0; i < 4 * 10101010; i++) T[i] = INF;
  scanf("%d%d", &N, &Q);
  for (int i = 2; i <= N; i++) {
    int x, w;
    scanf("%d%d", &x, &w);
    adj[i].push_back({x, w});
    adj[x].push_back({i, w});
    deg[i]++;
    deg[x]++;
  }
  init(1, 0);
  for (int i = 1; i <= 19; i++) {
    for (int j = 1; j <= N; j++) {
      sp[i][j] = sp[i - 1][sp[i - 1][j]];
      sm[i][j] = sm[i - 1][j] + sm[i - 1][sp[i - 1][j]];
    }
  }
  solve(1);
  while (Q--) {
    int v, l, r;
    scanf("%d%d%d", &v, &l, &r);
    long long ans = INF;
    long long s = 0;
    while (v) {
      ans = min(ans, s + query(v, l, r));
      s += dist(v, up[v]);
      v = up[v];
    }
    printf("%lld\n", ans);
  }
  return 0;
}
