#include <bits/stdc++.h>
using namespace std;
const int maxn = 555555;
const long long inf = 0x3f3f3f3f3f3f3f3f;
long long mi[maxn << 2];
long long lazy[maxn << 2];
long long sum[maxn << 2];
vector<pair<int, int> > g[maxn];
vector<pair<pair<int, int>, int> > que[maxn];
int n, q, mx_id;
int r[maxn];
long long ans[maxn];
void dfs1(int u, long long s) {
  mx_id = u;
  sum[u] = s;
  if (g[u].size() == 0) {
    r[u] = mx_id;
  } else {
    for (auto item : g[u]) {
      int v = item.first;
      int w = item.second;
      dfs1(v, s + w);
    }
    sum[u] = inf;
    r[u] = mx_id;
  }
}
void up(int rt) { mi[rt] = min(mi[rt << 1], mi[rt << 1 | 1]); }
void down(int rt) {
  if (lazy[rt]) {
    mi[rt << 1] += lazy[rt];
    mi[rt << 1 | 1] += lazy[rt];
    lazy[rt << 1] += lazy[rt];
    lazy[rt << 1 | 1] += lazy[rt];
    lazy[rt] = 0;
  }
}
void build(int l, int r, int rt) {
  if (l == r) {
    mi[rt] = sum[l];
    lazy[rt] = 0;
    return;
  }
  int m = (l + r) >> 1;
  build(l, m, rt << 1);
  build(m + 1, r, rt << 1 | 1);
  up(rt);
}
void update(int L, int R, int val, int l, int r, int rt) {
  if (L <= l && R >= r) {
    mi[rt] += val;
    lazy[rt] += val;
    return;
  }
  int m = (l + r) >> 1;
  down(rt);
  if (L <= m) update(L, R, val, l, m, rt << 1);
  if (R > m) update(L, R, val, m + 1, r, rt << 1 | 1);
  up(rt);
}
long long query(int L, int R, int l, int r, int rt) {
  if (L <= l && R >= r) {
    return mi[rt];
  }
  int m = (l + r) >> 1;
  down(rt);
  long long ans = inf;
  if (L <= m) ans = min(ans, query(L, R, l, m, rt << 1));
  if (R > m) ans = min(ans, query(L, R, m + 1, r, rt << 1 | 1));
  return ans;
}
void dfs2(int u) {
  for (auto qq : que[u]) {
    int id = qq.second;
    int li = qq.first.first;
    int ri = qq.first.second;
    ans[id] = query(li, ri, 1, n, 1);
  }
  for (auto item : g[u]) {
    int v = item.first;
    int w = item.second;
    int li = v, ri = r[v];
    update(li, ri, -w, 1, n, 1);
    if (1 < li) update(1, li - 1, w, 1, n, 1);
    if (ri < n) update(ri + 1, n, w, 1, n, 1);
    dfs2(v);
    update(li, ri, w, 1, n, 1);
    if (1 < li) update(1, li - 1, -w, 1, n, 1);
    if (ri < n) update(ri + 1, n, -w, 1, n, 1);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  while (cin >> n >> q) {
    for (int i = 2; i <= n; i++) {
      int pi, w;
      cin >> pi >> w;
      g[pi].push_back(make_pair(i, w));
    }
    for (int i = 0; i < q; i++) {
      int v, li, ri;
      cin >> v >> li >> ri;
      que[v].push_back(make_pair(make_pair(li, ri), i));
    }
    mx_id = 1;
    dfs1(1, 0);
    build(1, n, 1);
    dfs2(1);
    for (int i = 0; i < q; i++) cout << ans[i] << endl;
  }
  return 0;
}
