#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
const long long inf = 0x3f3f3f3f3f3f3f3f;
struct Query {
  int l, r, id;
  Query(int l = 0, int r = 0, int id = 0) : l(l), r(r), id(id) {}
};
int n, q, in[N], out[N], tot;
long long dis[N], mn[N << 2], tag[N << 2];
vector<pair<int, int> > G[N];
vector<Query> s[N];
vector<long long> ans;
void push_down(int rt) {
  if (tag[rt]) {
    mn[rt << 1] += tag[rt];
    mn[rt << 1 | 1] += tag[rt];
    tag[rt << 1] += tag[rt];
    tag[rt << 1 | 1] += tag[rt];
    tag[rt] = 0;
  }
}
void dfs(int u, long long dist) {
  in[u] = ++tot;
  if (!G[u].size()) {
    dis[tot] = dist;
  }
  for (auto& e : G[u]) {
    int v = e.first;
    dfs(v, dist + e.second);
  }
  out[u] = tot;
}
void build(int l, int r, int rt) {
  tag[rt] = 0;
  if (l == r) {
    mn[rt] = dis[l];
    return;
  }
  int mid = (l + r) / 2;
  build(l, mid, rt << 1);
  build(mid + 1, r, rt << 1 | 1);
  mn[rt] = min(mn[rt << 1], mn[rt << 1 | 1]);
}
void update(int ql, int qr, int k, int l, int r, int rt) {
  if (ql <= l && r <= qr) {
    tag[rt] += k;
    mn[rt] += k;
    return;
  }
  push_down(rt);
  int mid = (l + r) / 2;
  if (qr > mid) update(ql, qr, k, mid + 1, r, rt << 1 | 1);
  if (ql <= mid) update(ql, qr, k, l, mid, rt << 1);
  mn[rt] = min(mn[rt << 1], mn[rt << 1 | 1]);
}
long long query(int ql, int qr, int l, int r, int rt) {
  if (ql <= l && r <= qr) {
    return mn[rt];
  }
  push_down(rt);
  int mid = (l + r) / 2;
  long long ret = inf;
  if (qr > mid) ret = min(ret, query(ql, qr, mid + 1, r, rt << 1 | 1));
  if (ql <= mid) ret = min(ret, query(ql, qr, l, mid, rt << 1));
  mn[rt] = min(mn[rt << 1], mn[rt << 1 | 1]);
  return ret;
}
void solve(int u) {
  sort(s[u].begin(), s[u].end(),
       [&](Query x, Query y) { return x.l == y.l ? x.r < y.r : x.l < y.l; });
  for (Query& p : s[u]) {
    ans[p.id] = query(in[p.l], in[p.r], 1, tot, 1);
  }
  for (auto& e : G[u]) {
    update(1, tot, e.second, 1, tot, 1);
    update(in[e.first], out[e.first], -2 * e.second, 1, tot, 1);
    solve(e.first);
    update(1, tot, -e.second, 1, tot, 1);
    update(in[e.first], out[e.first], 2 * e.second, 1, tot, 1);
  }
}
int main() {
  memset(dis, 0x3f, sizeof(dis));
  scanf("%d%d", &n, &q);
  for (int i = 2, p, w; i <= n; i++) {
    scanf("%d%d", &p, &w);
    G[p].push_back(pair<int, int>(i, w));
  }
  for (int i = 0, u, l, r; i < q; i++) {
    scanf("%d%d%d", &u, &l, &r);
    s[u].emplace_back(l, r, i);
    ans.push_back(0);
  }
  dfs(1, 0);
  build(1, tot, 1);
  solve(1);
  for (auto x : ans) {
    printf("%lld ", x);
  }
  return 0;
}
