#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 5;
static int N, Q, M, beg[MAXN], fin[MAXN], ord[MAXN], q_l[MAXN], q_r[MAXN];
static vector<pair<int, int>> edge[MAXN];
static vector<int> asks[MAXN];
static long long dis[MAXN], add[MAXN << 2], mnd[MAXN << 2], q_a[MAXN];
inline void update(int n, long long delta) {
  add[n] += delta;
  mnd[n] += delta;
}
inline void push_down(int n) {
  if (add[n]) {
    update((n << 1), add[n]);
    update(((n << 1) | 1), add[n]);
    add[n] = 0;
  }
}
void modify(int n, int l, int r, int fl, int fr, long long delta) {
  if (fl <= l && r <= fr)
    update(n, delta);
  else {
    push_down(n);
    if (fl <= ((l + r) >> 1))
      modify((n << 1), l, ((l + r) >> 1), fl, fr, delta);
    if (fr >= (((l + r) >> 1) + 1))
      modify(((n << 1) | 1), (((l + r) >> 1) + 1), r, fl, fr, delta);
    mnd[n] = min(mnd[(n << 1)], mnd[((n << 1) | 1)]);
  }
}
long long query(int n, int l, int r, int fl, int fr) {
  if (fl <= l && r <= fr) return mnd[n];
  push_down(n);
  long long ret = LLONG_MAX;
  if (fl <= ((l + r) >> 1))
    ret = min(ret, query((n << 1), l, ((l + r) >> 1), fl, fr));
  if (fr >= (((l + r) >> 1) + 1))
    ret = min(ret, query(((n << 1) | 1), (((l + r) >> 1) + 1), r, fl, fr));
  return ret;
}
void dfs(int u) {
  if (edge[u].empty())
    ord[beg[u] = fin[u] = ++M] = u;
  else {
    beg[u] = M + 1;
    for (auto &pr : edge[u]) {
      int &v = pr.first, &w = pr.second;
      dis[v] = dis[u] + w;
      dfs(v);
    }
    fin[u] = M;
  }
}
void dfs_ans(int u) {
  for (int id : asks[u]) {
    int fl = lower_bound(ord + 1, ord + M + 1, q_l[id]) - ord;
    int fr = upper_bound(ord + 1, ord + M + 1, q_r[id]) - ord - 1;
    q_a[id] = query(1, 1, M, fl, fr);
  }
  for (auto &pr : edge[u]) {
    int &v = pr.first, &w = pr.second;
    modify(1, 1, M, 1, M, w);
    modify(1, 1, M, beg[v], fin[v], -2 * w);
    dfs_ans(v);
    modify(1, 1, M, 1, M, -w);
    modify(1, 1, M, beg[v], fin[v], 2 * w);
  }
}
int main() {
  scanf("%d%d", &N, &Q);
  for (int i = 2, p, w; i <= N; i++) {
    scanf("%d%d", &p, &w);
    edge[p].emplace_back(i, w);
  }
  for (int i = 1; i <= N; i++) sort(edge[i].begin(), edge[i].end());
  dfs(1);
  for (int i = 1; i <= N; i++)
    if (edge[i].empty()) modify(1, 1, M, beg[i], fin[i], dis[i]);
  for (int i = 0, v; i < Q; i++) {
    scanf("%d%d%d", &v, &q_l[i], &q_r[i]);
    asks[v].emplace_back(i);
  }
  dfs_ans(1);
  for (int i = 0; i < Q; i++) printf("%lld\n", q_a[i]);
  return 0;
}
