#include <bits/stdc++.h>
using namespace std;
int const N = int(5e5) + 7;
int w[N];
vector<int> gr[N];
int out[N];
int qrl[N], qrr[N];
vector<int> qri[N];
long long answers[N];
int indexes[N];
vector<long long> ld;
int len = 1;
int nn;
void dfs(int v, long long length = 0) {
  out[v] = v;
  indexes[v] = ld.size();
  for (int i = 0; i < gr[v].size(); ++i) {
    int u = gr[v][i];
    dfs(u, length + w[v]);
    out[v] = out[u];
  }
  if (out[v] == v) {
    ld.push_back(length + w[v]);
  }
}
long long segm[4 * N];
long long add[4 * N];
void build(int v = 1, int l = 0, int r = len) {
  if (l + 1 >= r) {
    segm[v] = ld[l];
    return;
  }
  int mid = (r + l) / 2;
  build(v << 1, l, mid);
  build((v << 1) + 1, mid, r);
  segm[v] = min(segm[v << 1], segm[(v << 1) + 1]);
}
void push(int v) {
  add[v << 1] += add[v];
  add[(v << 1) + 1] += add[v];
  add[v] = 0;
}
long long query(int ql, int qr, int v = 1, int l = 0, int r = len) {
  if (qr <= l || r <= ql) return ((long long)1) << 60;
  if (ql <= l && r <= qr) return segm[v] + add[v];
  push(v);
  int mid = (r + l) / 2;
  long long res = query(ql, qr, v << 1, l, mid);
  res = min(res, query(ql, qr, (v << 1) + 1, mid, r));
  segm[v] =
      min(segm[v << 1] + add[v << 1], segm[(v << 1) + 1] + add[(v << 1) + 1]);
  return res;
}
void update(int value, int ql, int qr, int v = 1, int l = 0, int r = len) {
  if (r <= ql || qr <= l) return;
  if (ql <= l && r <= qr) {
    add[v] += value;
    return;
  }
  push(v);
  int mid = (l + r) / 2;
  update(value, ql, qr, v << 1, l, mid);
  update(value, ql, qr, (v << 1) + 1, mid, r);
  segm[v] =
      min(segm[v << 1] + add[v << 1], segm[(v << 1) + 1] + add[(v << 1) + 1]);
}
void dfs2(int v) {
  update(-w[v], indexes[v], indexes[out[v]] + 1);
  update(w[v], 0, indexes[v]);
  update(w[v], indexes[out[v]] + 1, nn);
  for (int i = 0; i < qri[v].size(); ++i) {
    int ind = qri[v][i];
    int del = 0;
    if (qrr[ind] == out[qrr[ind]]) ++del;
    answers[ind] = query(indexes[qrl[ind]], indexes[qrr[ind]] + del);
  }
  for (int i = 0; i < gr[v].size(); ++i) {
    int u = gr[v][i];
    dfs2(u);
  }
  update(w[v], indexes[v], indexes[out[v]] + 1);
  update(-w[v], 0, indexes[v]);
  update(-w[v], indexes[out[v]] + 1, nn);
}
int main() {
  ios_base::sync_with_stdio(false);
  ifstream in("../../../input.txt");
  int n, q;
  cin >> n >> q;
  for (int i = 2; i <= n; ++i) {
    int pi;
    cin >> pi >> w[i];
    gr[pi].push_back(i);
  }
  for (int i = 0; i < q; ++i) {
    int v;
    cin >> v >> qrl[i] >> qrr[i];
    qri[v].push_back(i);
  }
  dfs(1);
  nn = ld.size();
  while (len < ld.size()) len <<= 1;
  ld.resize(len, ((long long)1) << 60);
  build();
  dfs2(1);
  for (int i = 0; i < q; ++i) cout << answers[i] << "\n";
  return 0;
}
