#include <bits/stdc++.h>
const long long MAX_N = 5e5 + 5;
const long long MAX_E = 1.2e6 + 5;
const long long MOD = 1e9 + 7;
using namespace std;
vector<pair<int, long long>> g[MAX_N];
pair<int, int> p[MAX_N];
vector<pair<pair<int, int>, int>> qs[MAX_N];
long long ans[MAX_N];
int fn[MAX_N];
long long mx[MAX_E];
long long fl[MAX_E];
int n, q, y;
void cl() {
  memset(fl, 0, sizeof fl);
  for (int i = 0; i < MAX_E; ++i) mx[i] = 1e17;
}
void shift(int k) {
  int l = k * 2;
  int r = l + 1;
  mx[l] += fl[k];
  mx[r] += fl[k];
  fl[l] += fl[k];
  fl[r] += fl[k];
  fl[k] = 0;
}
void update(int k) {
  int l = k * 2;
  int r = l + 1;
  mx[k] = min(mx[l], mx[r]);
}
void add(int l, int r, int a, int b, int k, long long d) {
  if (r < a or b < l) return;
  if (a <= l and r <= b) {
    fl[k] += d;
    mx[k] += d;
    return;
  }
  int mid = (l + r) / 2;
  shift(k);
  add(l, mid, a, b, k * 2, d);
  add(mid + 1, r, a, b, k * 2 + 1, d);
  update(k);
}
long long ask(int l, int r, int a, int b, int k) {
  if (r < a or b < l) return 1e18;
  if (a <= l and r <= b) return mx[k];
  int mid = (l + r) / 2;
  shift(k);
  return min(ask(l, mid, a, b, k * 2), ask(mid + 1, r, a, b, k * 2 + 1));
}
void df(int v) {
  fn[v] = 1;
  for (auto x : g[v]) {
    df(x.first);
    fn[v] += fn[x.first];
  }
}
void dfs1(int v) {
  if (v) add(0, y - 1, 0, v - 1, 1, p[v].second);
  for (auto x : g[v]) dfs1(x.first);
  if (!g[v].size()) add(0, y - 1, v, v, 1, -1e17);
  for (auto x : qs[v])
    ans[x.second] =
        min(ans[x.second], ask(0, y - 1, x.first.first, x.first.second, 1));
  add(0, y - 1, v, fn[v], 1, p[v].second);
  if (v) add(0, y - 1, 0, v - 1, 1, -p[v].second);
}
void dfs2(int v) {
  add(0, y - 1, v + 1, n - 1, 1, p[v].second);
  for (auto x : g[v]) dfs2(x.first);
  if (!g[v].size()) add(0, y - 1, v, v, 1, -1e17);
  for (auto x : qs[v])
    ans[x.second] =
        min(ans[x.second], ask(0, y - 1, x.first.first, x.first.second, 1));
  add(0, y - 1, v, fn[v], 1, p[v].second);
  add(0, y - 1, v + 1, n - 1, 1, -p[v].second);
}
int main() {
  for (int i = 0; i < MAX_N; ++i) ans[i] = 1e18;
  scanf("%d%d", &n, &q);
  y = (1 << ((int)ceil(log2(n))));
  for (int i = 1; i < n; ++i) {
    scanf("%d%d", &p[i].first, &p[i].second);
    p[i].first--;
    g[p[i].first].push_back({i, p[i].second});
  }
  df(0);
  for (int i = 0; i < n; ++i) fn[i] += i - 1;
  for (int i = 1; i <= q; ++i) {
    int v, l, r;
    scanf("%d%d%d", &v, &l, &r);
    l--, r--, v--;
    qs[v].push_back({{l, r}, i});
  }
  for (int i = 0; i < n; ++i) sort(g[i].begin(), g[i].end());
  cl();
  dfs1(0);
  for (int i = 0; i < n; ++i) reverse(g[i].begin(), g[i].end());
  cl();
  dfs2(0);
  for (int i = 1; i <= q; ++i) printf("%I64d\n", ans[i]);
  return 0;
}
