#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5000;
const long long mod = 1e9 + 7;
long long mul(long long a, long long b, long long c) {
  long long res = 1;
  while (b) {
    if (b & 1) res *= a, res %= c;
    a *= a, a %= c, b >>= 1;
  }
  return res;
}
long long phi(long long x) {
  long long res = x;
  for (long long i = 2; i * i <= x; i++) {
    if (x % i == 0) res = x / i * (i - 1);
    while (x % i == 0) x /= i;
  }
  if (x > 1) res = res / x * (x - 1);
  return res;
}
long long c, k;
vector<vector<pair<long long, long long> > > v;
int tot = 0;
int vis[maxn], l[maxn], r[maxn], n, q;
long long dis[maxn];
void dfs(int x, int fa, long long cur) {
  l[x] = ++tot;
  if (v[x].size())
    dis[x] = 0x3f3f3f3f3f3f3f3f;
  else
    dis[x] = cur;
  for (auto d : v[x]) {
    if (d.first != fa) {
      dfs(d.first, x, cur + d.second);
    }
  }
  r[x] = tot;
}
struct node {
  long long Min;
  long long lazy;
} no[maxn << 2];
void pushup(int id) { no[id].Min = min(no[id << 1].Min, no[id << 1 | 1].Min); }
void pushdown(int id) {
  no[id << 1].lazy += no[id].lazy;
  no[id << 1 | 1].lazy += no[id].lazy;
  no[id << 1].Min += no[id].lazy;
  no[id << 1 | 1].Min += no[id].lazy;
  no[id].lazy = 0;
}
void build(int id, int l, int r) {
  no[id].lazy = 0;
  if (l == r) {
    no[id].Min = dis[l];
    return;
  }
  int mid = (l + r) >> 1;
  build(id << 1, l, mid);
  build(id << 1 | 1, mid + 1, r);
  pushup(id);
}
void update(int id, int l, int r, int L, int R, long long w) {
  if (l >= L && r <= R) {
    no[id].lazy += w;
    no[id].Min += w;
    return;
  }
  if (no[id].lazy) pushdown(id);
  int mid = (l + r) >> 1;
  if (L <= mid) update(id << 1, l, mid, L, R, w);
  if (R > mid) update(id << 1 | 1, mid + 1, r, L, R, w);
  pushup(id);
}
long long query(int id, int l, int r, int L, int R) {
  if (l >= L && r <= R) return no[id].Min;
  if (no[id].lazy) pushdown(id);
  int mid = (l + r) >> 1;
  long long ans = 0x3f3f3f3f3f3f3f3f;
  if (L <= mid) ans = query(id << 1, l, mid, L, R);
  if (R > mid) ans = min(ans, query(id << 1 | 1, mid + 1, r, L, R));
  return ans;
}
struct queryans {
  int l, r, id;
  long long ans;
  queryans() {}
  queryans(int lll, int rr, int idd, long long ans) {
    l = lll, r = rr, id = idd, ans = 0;
  }
};
vector<queryans> ans[maxn];
long long anss[maxn];
void dfss(int x, long long w) {
  update(1, 1, n, 1, n, w);
  update(1, 1, n, l[x], r[x], -2ll * w);
  for (auto d : ans[x]) {
    anss[d.id] = query(1, 1, n, d.l, d.r);
  }
  for (auto d : v[x]) {
    long long w = d.second;
    int y = d.first;
    dfss(y, w);
  }
  update(1, 1, n, 1, n, -w);
  update(1, 1, n, l[x], r[x], 2ll * w);
}
int main() {
  ios::sync_with_stdio(false);
  while (cin >> n >> q) {
    tot = 0;
    v.resize(n + 200);
    memset(vis, 0, sizeof(vis));
    memset(dis, 0, sizeof(dis));
    for (int i = 2; i <= n; i++) {
      int u, vv;
      cin >> u >> vv;
      v[u].push_back(make_pair(i, vv));
    }
    dfs(1, 0, 0);
    build(1, 1, n);
    for (int i = 1; i <= q; i++) {
      long long x, long long, rr;
      cin >> x >> long long >> rr;
      ans[x].push_back(queryans(long long, rr, i, 0));
    }
    dfss(1, 0);
    printf("dasda\n");
    for (int i = 1; i <= q; i++) cout << anss[i] << endl;
  }
  return 0;
}
