#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 5e5 + 5;
const int ub = 1e6;
const double inf = 1e-4;
long long powmod(long long x, long long y) {
  long long t;
  for (t = 1; y; y >>= 1, x = x * x % mod)
    if (y & 1) t = t * x % mod;
  return t;
}
long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }
int n, q, x, y, z;
int pl[maxn], pr[maxn], d[maxn], tot = 0;
vector<pair<int, int>> g[maxn];
struct Q {
  int y, v, id;
};
vector<Q> qy[maxn];
long long tree[maxn << 2], lazy[maxn << 2];
long long dis[maxn], ans[maxn], INF = 1e18;
void build(int l, int r, int rt) {
  lazy[rt] = 0, tree[rt] = INF;
  if (l == r) {
    if (d[l] == 1) tree[rt] = dis[l];
    return;
  }
  int mid = l + r >> 1;
  build(l, mid, rt << 1), build(mid + 1, r, rt << 1 | 1);
  tree[rt] = min(tree[rt << 1], tree[rt << 1 | 1]);
}
void pushdown(int l, int r, int rt) {
  if (lazy[rt]) {
    lazy[rt << 1] += lazy[rt];
    lazy[rt << 1 | 1] += lazy[rt];
    tree[rt << 1] += lazy[rt];
    tree[rt << 1] = min(tree[rt << 1], INF);
    tree[rt << 1 | 1] += lazy[rt];
    tree[rt << 1 | 1] = min(tree[rt << 1 | 1], INF);
    lazy[rt] = 0;
  }
}
void update(int l, int r, int rt, int L, int R, int v) {
  if (L > R) return;
  if (L <= l && r <= R) {
    if (tree[rt] != INF) {
      tree[rt] -= v;
      lazy[rt] -= v;
    }
    return;
  }
  pushdown(l, r, rt);
  int mid = l + r >> 1;
  if (L <= mid) update(l, mid, rt << 1, L, R, v);
  if (mid < R) update(mid + 1, r, rt << 1 | 1, L, R, v);
  tree[rt] = min(tree[rt << 1], tree[rt << 1 | 1]);
}
long long query(int l, int r, int rt, int L, int R) {
  if (L <= l && r <= R) {
    return tree[rt];
  }
  pushdown(l, r, rt);
  int mid = l + r >> 1;
  long long ret = INF;
  if (L <= mid) ret = min(ret, query(l, mid, rt << 1, L, R));
  if (mid < R) ret = min(ret, query(mid + 1, r, rt << 1 | 1, L, R));
  return ret;
}
void dfs(int u, int fa) {
  pl[u] = ++tot;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i].first, len = g[u][i].second;
    if (v == fa) continue;
    dis[v] = dis[u] + len;
    dfs(v, u);
  }
  pr[u] = tot;
}
void solve(int u, int fa) {
  for (int(i) = (0); (i) < (qy[u].size()); (i)++) {
    int y = qy[u][i].y, v = qy[u][i].v, id = qy[u][i].id;
    ans[id] = query(1, n, 1, y, v);
  }
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i].first, len = g[u][i].second;
    if (v == fa) continue;
    update(1, n, 1, pl[v], pr[v], len);
    update(1, n, 1, 1, pl[v] - 1, -len), update(1, n, 1, pr[v] + 1, n, -len);
    solve(v, u);
    update(1, n, 1, pl[v], pr[v], -len);
    update(1, n, 1, 1, pl[v] - 1, len), update(1, n, 1, pr[v] + 1, n, len);
  }
}
int main() {
  scanf("%d%d", &n, &q);
  for (int(i) = (2); (i) < (n + 1); (i)++) {
    scanf("%d%d", &x, &y);
    g[i].push_back(make_pair(x, y));
    g[x].push_back(make_pair(i, y));
    d[i]++, d[x]++;
  }
  for (int(i) = (0); (i) < (q); (i)++) {
    scanf("%d%d%d", &x, &y, &z);
    qy[x].push_back(Q{y, z, i});
  }
  dis[1] = 0, tot = 0;
  dfs(1, -1), build(1, n, 1);
  solve(1, -1);
  for (int(i) = (0); (i) < (q); (i)++) printf("%d\n", ans[i]);
  return 0;
}
