#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-9;
const long double PI = acos(-1);
const int N = 5e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
vector<int> adj[N];
int n, m, lf[N], rt[N], t;
long long first[4 * N], lz[4 * N], val[N], ans[N], vis[N];
map<pair<int, int>, long long> wt;
struct qry {
  int id, l, r;
};
vector<qry> q[N];
void build(int p, int l, int r) {
  if (l == r) {
    first[p] = val[l];
    return;
  }
  int mid = (l + r) / 2;
  build(2 * p, l, mid);
  build(2 * p + 1, mid + 1, r);
  first[p] = min(first[2 * p], first[2 * p + 1]);
}
void push(int p, int l, int r) {
  if (lz[p]) {
    first[p] += lz[p];
    if (l != r) lz[2 * p] += lz[p];
    lz[2 * p + 1] += lz[p];
    lz[p] = 0;
  }
}
void update(int p, int l, int r, int i, int j, long long x) {
  push(p, l, r);
  if (r < i or l > j) return;
  if (i <= l and r <= j) {
    lz[p] += x;
    push(p, l, r);
    return;
  }
  int mid = (l + r) / 2;
  update(2 * p, l, mid, i, j, x);
  update(2 * p + 1, mid + 1, r, i, j, x);
  first[p] = min(first[2 * p], first[2 * p + 1]);
}
long long query(int p, int l, int r, int i, int j) {
  push(p, l, r);
  if (r < i or l > j) return LINF;
  if (i <= l and r <= j) {
    return first[p];
  }
  int mid = (l + r) / 2;
  return min(query(2 * p, l, mid, i, j), query(2 * p + 1, mid + 1, r, i, j));
}
void set_interval(int u) {
  lf[u] = rt[u] = ++t;
  for (int v : adj[u])
    if (!vis[v]) {
      vis[v] = vis[u] + wt[{u, v}];
      set_interval(v);
    }
  rt[u] = t;
}
void up(int l, int r, long long x) {
  if (l <= r) update(1, 1, n, l, r, x);
}
void dfs(int u) {
  vis[u] = 1;
  for (auto p : q[u]) {
    ans[p.id] = query(1, 1, n, p.l, p.r);
  }
  for (int v : adj[u])
    if (!vis[v]) {
      long long w = wt[{u, v}];
      up(1, lf[v] - 1, w);
      up(lf[v], rt[v], -w);
      up(rt[v] + 1, n, w);
      dfs(v);
      up(1, lf[v] - 1, -w);
      up(lf[v], rt[v], w);
      up(rt[v] + 1, n, -w);
    }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 2; i <= n; i++) {
    int u;
    long long x;
    scanf("%d %lld", &u, &x);
    adj[u].push_back(i);
    adj[i].push_back(u);
    wt[{u, i}] = wt[{i, u}] = x;
  }
  for (int i = 0; i < m; i++) {
    int v, l, r;
    scanf("%d %d %d", &v, &l, &r);
    q[v].push_back({i, l, r});
  }
  vis[1] = 1;
  set_interval(1);
  for (int i = 1; i <= n; i++) {
    val[i] = adj[i].size() == 1 ? (long long)vis[i] - 1 : LINF;
  }
  build(1, 1, n);
  memset(vis, 0, sizeof vis);
  dfs(1);
  for (int i = 0; i < m; i++) printf("%lld\n", ans[i]);
  return 0;
}
