#include <bits/stdc++.h>
using namespace std;
const int DN = 1e6 + 15;
int n, q, f, g, w, pr[2][DN];
int a[DN], nr, rs[DN], rd[DN], viz[DN], k, ls, ld, pz;
int nod, zs[DN], zd[DN], cnt, zz[DN];
long long rez[DN], arb[2][4 * DN], poz, val, mi;
vector<pair<int, int> > v[DN];
vector<pair<int, pair<int, int> > > z[DN];
void dfs(int nod) {
  nr++;
  rs[nod] = nr;
  cnt++;
  zz[cnt] = nr;
  a[nr] = nod;
  for (auto i : v[nod])
    if (i.first != pr[0][nod]) {
      pr[0][i.first] = nod;
      pr[1][i.first] = i.second;
      dfs(i.first);
    }
  nr++;
  rd[nod] = nr;
  a[nr] = nod;
}
void update(int nod, int st, int dr) {
  if (st == dr) {
    arb[0][nod] = arb[1][nod] + val;
    return;
  }
  int mij = (st + dr) / 2;
  if (poz <= mij)
    update(2 * nod, st, mij);
  else
    update(2 * nod + 1, mij + 1, dr);
  arb[0][nod] = arb[1][nod] + min(arb[0][2 * nod], arb[0][2 * nod + 1]);
}
void update2(int nod, int st, int dr) {
  if (st > ld) return;
  if (dr < ls) return;
  if (ls <= st && dr <= ld) {
    arb[1][nod] += val;
    arb[0][nod] += val;
    return;
  }
  int mij = (st + dr) / 2;
  update2(2 * nod, st, mij);
  update2(2 * nod + 1, mij + 1, dr);
  arb[0][nod] = arb[1][nod] + min(arb[0][2 * nod], arb[0][2 * nod + 1]);
}
void query(int nod, int st, int dr, long long sum) {
  if (st > ld) return;
  if (dr < ls) return;
  if (ls <= st && dr <= ld) {
    mi = min(mi, sum + arb[0][nod]);
    return;
  }
  int mij = (st + dr) / 2;
  sum += arb[1][nod];
  query(2 * nod, st, mij, sum);
  query(2 * nod + 1, mij + 1, dr, sum);
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; i++) {
    f = i;
    scanf("%d%d", &g, &w);
    v[f].push_back({g, w});
    v[g].push_back({f, w});
  }
  for (int i = 1; i <= q; i++) {
    scanf("%d%d%d", &k, &ls, &ld);
    z[k].push_back({i, {ls, ld}});
    rez[i] = 1e18;
  }
  for (int i = 1; i <= n; i++) sort(v[i].begin(), v[i].end());
  {
    nr = 0;
    cnt = 0;
    dfs(1);
    for (int i = 1; i < 4 * DN; i++) {
      arb[0][i] = 1e16;
      arb[1][i] = 0;
    }
    for (int i = 1; i <= nr; i++) {
      nod = a[i];
      viz[nod] = 1 - viz[nod];
      poz = i;
      val = 0;
      if (v[nod].size() == 1 && viz[nod] == 1) {
        update(1, 1, nr);
      }
      if (viz[nod] == 1) {
        ls = 1;
        ld = i - 1;
        val = pr[1][nod];
        update2(1, 1, nr);
      }
      for (auto j : z[nod]) {
        pz = j.first;
        ls = zz[j.second.first];
        ld = zz[j.second.second];
        mi = 1e18;
        query(1, 1, nr, 0);
        rez[pz] = min(rez[pz], mi);
      }
      if (viz[nod] == 0) {
        ls = rs[nod];
        ld = rd[nod];
        val = pr[1][nod];
        update2(1, 1, nr);
      }
      if (viz[nod] == 0) {
        ls = 1;
        ld = rs[nod] - 1;
        val = -pr[1][nod];
        update2(1, 1, nr);
      }
    }
    for (int i = 1; i < 4 * DN; i++) {
      arb[0][i] = 1e16;
      arb[1][i] = 0;
    }
    for (int i = nr; i > 0; i--) {
      nod = a[i];
      viz[nod] = 1 - viz[nod];
      poz = i;
      val = 0;
      if (v[nod].size() == 1 && viz[nod] == 0) {
        update(1, 1, nr);
      }
      if (viz[nod] == 1) {
        ls = i + 1;
        ld = nr;
        val = pr[1][nod];
        update2(1, 1, nr);
      }
      for (auto j : z[nod]) {
        pz = j.first;
        ls = zz[j.second.first];
        ld = zz[j.second.second];
        mi = 1e18;
        query(1, 1, nr, 0);
        rez[pz] = min(rez[pz], mi);
      }
      if (viz[nod] == 0) {
        ls = rs[nod];
        ld = rd[nod];
        val = pr[1][nod];
        update2(1, 1, nr);
      }
      if (viz[nod] == 0) {
        ls = rd[nod] + 1;
        ld = nr;
        val = -pr[1][nod];
        update2(1, 1, nr);
      }
    }
  }
  for (int i = 1; i <= q; i++) cout << rez[i] << '\n';
}
