#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 100;
const long long inf = 0x3f3f3f3f3f3f3f;
struct sa {
  int id, l, r;
};
vector<pair<int, int> > g[maxn];
vector<sa> qy[maxn];
int rl[maxn], rr[maxn];
long long dis[maxn], ans[maxn];
long long lazy[maxn << 2], val[maxn << 2];
void dfs(int u, int f, int &id, long long d) {
  rl[u] = ++id;
  if (g[u].size())
    dis[id] = inf;
  else
    dis[id] = d;
  for (auto i : g[u]) {
    if (i.first == f) continue;
    dfs(i.first, u, id, d + i.second);
  }
  rr[u] = id;
}
void push_up(int p) { val[p] = min(val[p << 1], val[p << 1 | 1]); }
void push_down(int p) {
  if (lazy[p]) {
    val[p << 1] += lazy[p];
    val[p << 1 | 1] += lazy[p];
    lazy[p << 1] += lazy[p];
    lazy[p << 1 | 1] += lazy[p];
    lazy[p] = 0;
  }
}
void build(int l, int r, int p) {
  lazy[p] = 0;
  if (l == r) {
    val[p] = dis[l];
    return;
  }
  int mid = (l + r) / 2;
  build(l, mid, p << 1);
  build(mid + 1, r, p << 1 | 1);
  push_up(p);
}
void update(int l, int r, int L, int R, int p, long long v) {
  if (L <= l && R >= r) {
    val[p] += v;
    lazy[p] += v;
    return;
  }
  push_down(p);
  int mid = (l + r) / 2;
  if (L <= mid) {
    update(l, mid, L, R, p << 1, v);
  }
  if (R > mid) {
    update(mid + 1, r, L, R, p << 1 | 1, v);
  }
  push_up(p);
}
long long query(int l, int r, int L, int R, int p) {
  if (L <= l && R >= r) {
    return val[p];
  }
  push_down(p);
  int mid = (l + r) / 2;
  long long ans = inf;
  if (L <= mid) {
    ans = min(ans, query(l, mid, L, R, p << 1));
  }
  if (R > mid) {
    ans = min(ans, query(mid + 1, r, L, R, p << 1 | 1));
  }
  push_up(p);
  return ans;
}
void dfs1(int u, int f, int n, int w) {
  update(1, n, 1, n, 1, w);
  update(1, n, rl[u], rr[u], 1, -2LL * w);
  for (auto i : qy[u]) {
    ans[i.id] = query(1, n, i.l, i.r, 1);
  }
  for (auto i : g[u]) {
    if (i.first == f) continue;
    dfs1(i.first, u, n, i.second);
  }
  update(1, n, 1, n, 1, -w);
  update(1, n, rl[u], rr[u], 1, 2LL * w);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < n - 1; ++i) {
    int p, w;
    cin >> p >> w;
    g[p].push_back({i + 2, w});
  }
  int num = 0;
  dfs(1, -1, num, 0);
  build(1, n, 1);
  for (int i = 0; i < q; ++i) {
    int x, l, r;
    cin >> x >> l >> r;
    qy[x].push_back({i, l, r});
  }
  dfs1(1, -1, n, 0);
  for (int i = 0; i < q; ++i) {
    cout << ans[i] << endl;
  }
  return 0;
}
