#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 5e5 + 5;
const long long INF = 1e18;
int solve();
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
vector<pair<long long, long long> > g[MAX_N];
vector<int> ancestors[MAX_N];
int centroid;
int depth[MAX_N];
int sz[MAX_N];
int ans[MAX_N];
long long dist[20][MAX_N];
void calcSz(int v, int p = -1) {
  sz[v] = 1;
  for (pair<long long, long long> to : g[v]) {
    if (to.first == p || depth[to.first] != -1) {
      continue;
    }
    calcSz(to.first, v);
    sz[v] += sz[to.first];
  }
}
void findCentroid(int v, int k, int p = -1) {
  for (pair<long long, long long> to : g[v]) {
    if (to.first == p || depth[to.first] != -1) {
      continue;
    }
    if (sz[to.first] > k / 2) {
      findCentroid(to.first, k, v);
    }
  }
  if (centroid == -1) {
    centroid = v;
  }
}
int nextID = 1;
int id[MAX_N];
bool leaf[MAX_N];
void dfsEuler(int v, int p = -1) {
  if (p != -1 && (int)g[v].size() == 1) {
    leaf[v] = true;
  }
  id[v] = nextID++;
  for (pair<long long, long long> to : g[v]) {
    if (to.first != p) {
      dfsEuler(to.first, v);
    }
  }
}
vector<pair<long long, long long> > vec[MAX_N];
void calcDist(int v, int curCentroid, int p = -1, long long curDist = 0) {
  dist[depth[curCentroid]][v] = curDist;
  ancestors[v].push_back(curCentroid);
  if (leaf[v]) {
    vec[curCentroid].push_back(make_pair(id[v], curDist));
  }
  for (pair<long long, long long> to : g[v]) {
    if (to.first == p || depth[to.first] != -1) {
      continue;
    }
    calcDist(to.first, curCentroid, v, curDist + to.second);
  }
}
vector<long long> t[MAX_N];
long long get(int head, int l, int r) {
  long long leftRes = INF;
  long long rightRes = INF;
  while (l < r) {
    if (l % 2 == 0) {
      leftRes = min(leftRes, t[head][l]);
    }
    l = l / 2;
    if (r % 2 == 1) {
      rightRes = min(rightRes, t[head][r]);
    }
    r = r / 2 - 1;
  }
  if (l == r) {
    leftRes = min(leftRes, t[head][l]);
  }
  return min(leftRes, rightRes);
}
void buildSegmentTree(int v) {
  t[v].resize(2 * (int)vec[v].size());
  if ((int)vec[v].size() == 0) {
    return;
  }
  for (int i = 0; i < (int)vec[v].size(); ++i) {
    t[v][(int)vec[v].size() - 1 + i] = vec[v][i].second;
  }
  for (int i = (int)vec[v].size() - 2; i >= 0; --i) {
    t[v][i] = min(t[v][2 * i + 1], t[v][2 * i + 2]);
  }
}
void buildDecomposition(int v, int p = -1, int curDepth = 0) {
  calcSz(v);
  centroid = -1;
  findCentroid(v, sz[v]);
  int curCentroid = centroid;
  depth[curCentroid] = curDepth;
  calcDist(curCentroid, curCentroid);
  sort(vec[curCentroid].begin(), vec[curCentroid].end());
  buildSegmentTree(curCentroid);
  for (pair<long long, long long> to : g[curCentroid]) {
    if (depth[to.first] == -1 && to.first != p) {
      buildDecomposition(to.first, curCentroid, curDepth + 1);
    }
  }
}
long long ask(int v, int l, int r) {
  int indl =
      lower_bound(vec[v].begin(), vec[v].end(), make_pair((long long)l, -1ll)) -
      vec[v].begin();
  int indr = upper_bound(vec[v].begin(), vec[v].end(),
                         make_pair((long long)r + 1, -1ll)) -
             vec[v].begin();
  indr--;
  return get(v, (int)vec[v].size() - 1 + indl, (int)vec[v].size() - 1 + indr);
}
long long query(int v, int l, int r) {
  long long res = INF;
  for (int it : ancestors[v]) {
    res = min(res, dist[depth[it]][v] + ask(it, l, r));
  }
  return res;
}
int n;
int q;
int solve() {
  cin >> n >> q;
  for (int i = 2; i <= n; ++i) {
    int a;
    long long w;
    cin >> a >> w;
    g[a].push_back(make_pair(i, w));
    g[i].push_back(make_pair(a, w));
  }
  dfsEuler(1);
  for (int i = 1; i <= n; ++i) {
    depth[i] = -1;
  }
  buildDecomposition(1);
  for (int i = 0; i < q; ++i) {
    int a;
    int l;
    int r;
    cin >> a >> l >> r;
    cout << query(a, l, r) << '\n';
  }
  return 0;
}
