#include <bits/stdc++.h>
using namespace std;
int n, m;
int n2;
vector<long long> ans;
vector<vector<pair<int, int> > > vv;
vector<long long> ll;
vector<queue<pair<int, int> > > zap;
vector<long long> dist;
vector<long long> tree;
vector<long long> treh;
vector<queue<int> > zep;
vector<pair<int, int> > zad;
int h;
void push(int p) {
  for (int i = h; i > 0; i--) {
    if ((p >> i) <= 0) continue;
    int nt = p >> i;
    if (treh[nt] != 0)
      treh[nt << 1] += treh[nt], treh[nt << 1 ^ 1] += treh[nt],
          tree[nt] += treh[nt];
    treh[nt] = 0;
  }
}
long long get(int l, int r) {
  long long anse = 1000000000000000;
  for (l += n2, r += n2; l < r; l >>= 1, r >>= 1) {
    if (l & 1) push(l), anse = min(anse, treh[l] + tree[l]), l++;
    if (r & 1) push(--r), anse = min(anse, tree[r] + treh[r]);
  }
  return anse;
}
void tra(int p) {
  while (p > 1) {
    p >>= 1;
    tree[p] =
        min(tree[p << 1] + treh[p << 1], tree[p << 1 | 1] + treh[p << 1 | 1]);
  }
}
void query(int l, int r, long long pr) {
  for (l += n2, r += n2; l < r; l >>= 1, r >>= 1) {
    if (l & 1) treh[l] += pr, tra(l++);
    if (r & 1) treh[--r] += pr, tra(r);
  }
}
void DODHIS(int v, int p = -1) {
  while (zap[v].size()) {
    pair<int, int> a = zap[v].front();
    zap[v].pop();
    ans[zep[v].front()] = get(a.first, a.second + 1);
    zep[v].pop();
  }
  for (int i = 0; i < vv[v].size(); i++) {
    int too = vv[v][i].first;
    if (too == p) continue;
    long long pr = vv[v][i].second;
    pair<int, int> lr = zad[too];
    if (lr.first > 0) query(0, lr.first, pr);
    if (lr.second + 1 < ll.size()) query(lr.second + 1, ll.size(), pr);
    query(lr.first, lr.second + 1, -pr);
    DODHIS(too, v);
    pr = -pr;
    if (lr.first > 0) query(0, lr.first, pr);
    if (lr.second + 1 < ll.size()) query(lr.second + 1, ll.size(), pr);
    query(lr.first, lr.second + 1, -pr);
  }
}
void build() {
  for (int i = n2 - 1; i > 0; i--)
    tree[i] = min(tree[i << 1], tree[i << 1 | 1]);
}
void zadira(int v, int p) {
  if (vv[v].size() != 1) zad[v] = {10000000, -10000000};
  for (int i = 0; i < vv[v].size(); i++) {
    int to = vv[v][i].first;
    if (to == p) continue;
    zadira(to, v);
    zad[v].first = min(zad[to].first, zad[v].first);
    zad[v].second = max(zad[to].second, zad[v].second);
  }
}
void dfs(int v, int p) {
  for (int i = 0; i < vv[v].size(); i++) {
    int to = vv[v][i].first;
    if (to == p) continue;
    dist[to] = dist[v] + vv[v][i].second;
    dfs(to, v);
  }
}
signed main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  cin >> n;
  dist.resize(n);
  vv.resize(n);
  zap.resize(n);
  zep.resize(n);
  zad.resize(n);
  cin >> m;
  ans.resize(m);
  for (int i = 0; i < n - 1; i++) {
    int a, b, c;
    cin >> a >> c;
    a--;
    vv[i + 1].push_back({a, c});
  }
  for (int i = 0; i < n; i++) {
    if (vv[i].size() == 1) {
      ll.push_back(i);
      zad[i] = {ll.size() - 1, ll.size() - 1};
    }
  }
  while ((1 << h) <= ll.size()) {
    h++;
  }
  for (int i = 0; i < m; i++) {
    int v, l, r;
    cin >> v >> l >> r;
    v--;
    l--;
    r--;
    int x = lower_bound(ll.begin(), ll.end(), l) - ll.begin();
    int y = lower_bound(ll.begin(), ll.end(), r) - ll.begin();
    if (ll[y] != r) y--;
    zap[v].push({x, y});
    zep[v].push(i);
  }
  dfs(0, -1);
  n2 = ll.size();
  tree.resize(2 * n2);
  treh.resize(2 * n2);
  for (int i = 0; i < ll.size(); i++) {
    tree[i + n2] = dist[ll[i]];
  }
  zadira(0, -1);
  build();
  DODHIS(0);
  for (int i = 0; i < m; i++) {
    cout << ans[i] << "\n";
  }
  cin >> n;
}
