#include <bits/stdc++.h>
using namespace std;
const int inf = 2e9 + 5;
const long long INF = 8e18;
const int B = (1 << 19);
long long w[2 * B], W[2 * B];
int leftl[B], rightl[B];
vector<pair<int, int> > adj[B];
long long d[B];
struct Query {
  int id, l, r;
};
vector<Query> Q[B];
int n, q;
void insert(int a, int b, int val, int v = 1, int va = 1, int vb = B) {
  if (a > b) return;
  if (va > b || vb < a) return;
  if (va >= a && vb <= b) {
    w[v] += val;
    W[v] += val;
    return;
  }
  int vmid = (va + vb) / 2;
  insert(a, b, val, 2 * v, va, vmid);
  insert(a, b, val, 2 * v + 1, vmid + 1, vb);
  W[v] = w[v] + min(W[2 * v], W[2 * v + 1]);
}
long long query(int a, int b, int v = 1, int va = 1, int vb = B,
                long long s = 0) {
  if (va > b || vb < a) return INF;
  if (va >= a && vb <= b) return s + W[v];
  int vmid = (va + vb) / 2;
  return min(query(a, b, 2 * v, va, vmid, s + w[v]),
             query(a, b, 2 * v + 1, vmid + 1, vb, s + w[v]));
}
void build() {
  for (int i = B; i <= 2 * B - 1; ++i) W[i] = w[i] = d[i - B + 1];
  for (int i = B - 1; i >= 1; --i) W[i] = min(W[2 * i], W[2 * i + 1]);
}
void dfs(int x) {
  for (pair<int, int> e : adj[x]) {
    d[e.first] = d[x] + e.second;
    dfs(e.first);
  }
  if ((int)(adj[x]).size() == 0) {
    leftl[x] = x;
    rightl[x] = x;
    return;
  }
  leftl[x] = inf;
  rightl[x] = -inf;
  for (pair<int, int> e : adj[x]) {
    leftl[x] = min(leftl[x], leftl[e.first]);
    rightl[x] = max(rightl[x], rightl[e.first]);
  }
}
long long res[B];
void dfs1(int x) {
  for (Query quer : Q[x]) {
    res[quer.id] = query(quer.l, quer.r);
  }
  for (pair<int, int> e : adj[x]) {
    insert(leftl[e.first], rightl[e.first], -e.second);
    insert(1, leftl[e.first] - 1, e.second);
    insert(rightl[e.first] + 1, n, e.second);
    dfs1(e.first);
    insert(leftl[e.first], rightl[e.first], e.second);
    insert(1, leftl[e.first] - 1, -e.second);
    insert(rightl[e.first] + 1, n, -e.second);
  }
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; ++i) {
    int p, wei;
    scanf("%d%d", &p, &wei);
    adj[p].push_back({i, wei});
  }
  dfs(1);
  for (int i = 1; i <= q; ++i) {
    int v, l, r;
    scanf("%d%d%d", &v, &l, &r);
    Q[v].push_back({i, l, r});
  }
  for (int i = 1; i <= n; ++i) {
    if ((int)(adj[i]).size() > 0) d[i] = INF;
  }
  build();
  dfs1(1);
  for (int i = 1; i <= q; ++i) {
    printf("%lld\n", res[i]);
  }
}
