#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10;
const long long INF = 1e18;
int n, q, sub[maxn];
long long sum[maxn], la[4 * maxn], mn[4 * maxn], ans[maxn];
vector<pair<int, int> > g[maxn];
vector<pair<pair<int, int>, int> > qu[maxn];
void dfs1(int v, int p) {
  sub[v] = 1;
  for (auto uu : g[v]) {
    int u = uu.first, w = uu.second;
    if (u != p) {
      sum[u] = sum[v] + w;
      dfs1(u, v);
      sub[v] += sub[u];
    }
  }
}
void build(int l = 1, int r = n, int node = 1) {
  if (l == r) {
    if (g[l].size() == 1) {
      mn[node] = sum[l];
    } else {
      mn[node] = INF;
    }
    return;
  }
  int mid = (r + l) / 2;
  build(l, mid, 2 * node);
  build(mid + 1, r, (2 * node) + 1);
  mn[node] = min(mn[2 * node], mn[(2 * node) + 1]);
}
void shift(int l, int r, int node) {
  mn[node] += la[node];
  if (l == r) {
    la[node] = 0;
    return;
  }
  la[2 * node] += la[node];
  la[(2 * node) + 1] += la[node];
  la[node] = 0;
}
void add(int x, int y, int va, int l = 1, int r = n, int node = 1) {
  shift(l, r, node);
  if (l > y || r < x) return;
  if (l >= x && r <= y) {
    la[node] += va;
    shift(l, r, node);
    return;
  }
  int mid = (r + l) / 2;
  add(x, y, va, l, mid, 2 * node);
  add(x, y, va, mid + 1, r, (2 * node) + 1);
  mn[node] = min(mn[2 * node], mn[(2 * node) + 1]);
}
long long getmin(int x, int y, int l = 1, int r = n, int node = 1) {
  shift(l, r, node);
  if (l > y || r < x) return INF;
  if (l >= x && r <= y) return mn[node];
  int mid = (r + l) / 2;
  return min(getmin(x, y, l, mid, 2 * node),
             getmin(x, y, mid + 1, r, (2 * node) + 1));
}
void dfs2(int v, int p) {
  for (auto p : qu[v]) {
    int l = p.first.first, r = p.first.second, id = p.second;
    ans[id] = getmin(l, r);
  }
  for (auto uu : g[v]) {
    int u = uu.first, w = uu.second;
    if (u != p) {
      add(u, u + sub[u] - 1, -w);
      if (u >= 2) add(1, u - 1, w);
      if ((u + sub[u]) <= n) add(u + sub[u], n, w);
      dfs2(u, v);
      add(u, u + sub[u] - 1, w);
      if (u >= 2) add(1, u - 1, -w);
      if ((u + sub[u]) <= n) add(u + sub[u], n, -w);
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> q;
  for (int i = 2; i <= n; i++) {
    int v, w;
    cin >> v >> w;
    g[v].push_back({i, w});
    g[i].push_back({v, w});
  }
  dfs1(1, 0);
  for (int i = 1; i <= q; i++) {
    int l, r, v;
    cin >> v >> l >> r;
    qu[v].push_back({{l, r}, i});
  }
  build();
  dfs2(1, 0);
  for (int i = 1; i <= q; i++) cout << ans[i] << "\n";
  return 0;
}
