#include <bits/stdc++.h>
using namespace std;
const long long int M = 5e5 + 5;
vector<pair<long long int, long long int> > vtr[M];
long long int cpt[M];
bool vis[M];
long long int n;
long long int sub[M];
long long int lvl[M];
long long int pt[M];
long long int wt[M], ind[M];
bool leaf[M];
std::vector<long long int> q[M], sp[M][22];
pair<long long int, long long int> anc[M][22];
void dfs(long long int x, long long int p) {
  sub[x] = 1;
  if ((long long int)vtr[x].size() == 1) leaf[x] = 1;
  for (long long int i = 0; i < vtr[x].size(); i++) {
    long long int v = vtr[x][i].first;
    if (v != p && !vis[v]) {
      dfs(v, x);
      sub[x] += sub[v];
    }
  }
}
long long int findctr(long long int x, long long int par, long long int elem) {
  for (long long int i = 0; i < vtr[x].size(); i++) {
    long long int v = vtr[x][i].first;
    if (v != par && !vis[v]) {
      if (sub[v] > elem / 2) return findctr(v, x, elem);
    }
  }
  return x;
}
void decompose(long long int v, long long int par) {
  dfs(v, par);
  long long int elem = sub[v];
  long long int cent = findctr(v, par, elem);
  cpt[cent] = par;
  vis[cent] = 1;
  for (long long int i = 0; i < vtr[cent].size(); i++) {
    if (vtr[cent][i].first != par && !vis[vtr[cent][i].first])
      decompose(vtr[cent][i].first, cent);
  }
}
void DFS(long long int x, long long int p, long long int l) {
  lvl[x] = l;
  for (long long int i = 0; i < vtr[x].size(); i++) {
    long long int u = vtr[x][i].first;
    if (u != p) {
      DFS(u, x, l + 1);
    }
  }
}
void pre() {
  long long int i, j;
  for (i = 1; i <= n; i++) {
    anc[i][0].first = pt[i];
    anc[i][0].second = wt[i];
  }
  for (j = 1; j <= 20; j++) {
    for (i = 1; i <= n; i++) {
      anc[i][j].first = anc[anc[i][j - 1].first][j - 1].first;
      anc[i][j].second =
          anc[i][j - 1].second + anc[anc[i][j - 1].first][j - 1].second;
    }
  }
}
long long int findLca(long long int p, long long int q) {
  long long int i;
  long long int s = 0;
  if (lvl[p] < lvl[q]) {
    long long int temp = p;
    p = q;
    q = temp;
  }
  long long int log;
  for (log = 1; 1 << log <= lvl[p]; log++)
    ;
  for (i = log; i >= 0; i--) {
    if (lvl[p] - (1 << i) >= lvl[q]) {
      s += anc[p][i].second;
      p = anc[p][i].first;
    }
  }
  if (p == q) return s;
  long long int x, y;
  for (i = log; i >= 0; i--) {
    x = anc[p][i].first;
    y = anc[q][i].first;
    if (x != y) {
      s += anc[p][i].second;
      s += anc[q][i].second;
      p = x;
      q = y;
    }
  }
  return s + wt[p] + wt[q];
}
long long int dist(long long int x, long long int y) {
  return (lvl[x] + lvl[y] - 2 * lvl[findLca(x, y)]);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int i, u, v, w, m;
  cin >> n >> m;
  for (i = 2; i <= n; i++) {
    cin >> pt[i] >> w;
    wt[i] = w;
    vtr[i].push_back(make_pair(pt[i], w));
    vtr[pt[i]].push_back(make_pair(i, w));
  }
  long long int curr = 0;
  for (i = 1; i <= M - 3; i++) {
    long long int b = 1 << (1 + curr);
    if (b >= i) ind[i] = curr;
    if (b == i) curr++;
  }
  DFS(1, 0, 1);
  pre();
  decompose(1, -1);
  long long int type, x, y, ans, l, r;
  for (long long int i = 1; i <= n; i++) {
    if (leaf[i] == 0) continue;
    y = i;
    while (y != -1) {
      q[y].push_back(i);
      y = cpt[y];
    }
  }
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 0; j < (long long int)q[i].size(); j++)
      sp[i][0].push_back(findLca(i, q[i][j]));
    for (long long int j = 1; j <= 20; j++) {
      for (long long int k = 0; k < (long long int)q[i].size(); k++) {
        long long int p = k + (1 << j);
        if (p < (long long int)sp[i][j - 1].size()) {
          sp[i][j].push_back(min(sp[i][j - 1][k], sp[i][j - 1][p]));
        } else
          sp[i][j].push_back(min(sp[i][j - 1][k], (long long int)1e16));
      }
    }
  }
  while (m--) {
    cin >> x >> l >> r;
    y = x;
    long long int ans = 1e16;
    while (y != -1) {
      long long int a = lower_bound(q[y].begin(), q[y].end(), l) - q[y].begin();
      long long int b = upper_bound(q[y].begin(), q[y].end(), r) - q[y].begin();
      b--;
      if (a <= b) {
        long long int len = (b - a + 1);
        len = ind[len];
        long long int p = (1 << len);
        long long int vl = min(sp[y][len][a], sp[y][len][b - p + 1]);
        vl += findLca(x, y);
        ans = min(ans, vl);
      }
      y = cpt[y];
    }
    cout << ans << endl;
  }
}
