#include <bits/stdc++.h>
using namespace std;
const int maxn = 500005;
const long long inf = 0x3f3f3f3f3f3f3f3f;
vector<pair<int, long long> > v[maxn];
vector<pair<pair<int, int>, int> > vv[maxn];
int in[maxn];
int out[maxn];
long long a[maxn];
long long ans[maxn];
int cnt, n;
struct node {
  long long Min;
  long long lazy;
} no[maxn << 2];
void dfs(int u, long long ans) {
  in[u] = ++cnt;
  if (v[u].size())
    a[cnt] = inf;
  else
    a[cnt] = ans;
  for (pair<int, long long> v1 : v[u]) {
    dfs(v1.first, ans + v1.second);
  }
  out[u] = cnt;
}
void pushup(int id) { no[id].Min = min(no[id << 1].Min, no[id << 1 | 1].Min); }
void pushdown(int id) {
  no[id << 1].lazy += no[id].lazy;
  no[id << 1 | 1].lazy += no[id].lazy;
  no[id << 1].Min += no[id].lazy;
  no[id << 1 | 1].Min += no[id].lazy;
  no[id].lazy = 0;
}
void build(int id, int l, int r) {
  no[id].lazy = 0;
  if (l == r) {
    no[id].Min = a[l];
    return;
  }
  int mid = (l + r) >> 1;
  build(id << 1, l, mid);
  build(id << 1 | 1, mid + 1, r);
  pushup(id);
}
void update(int id, int l, int r, int L, int R, long long w) {
  if (l >= L && r <= R) {
    no[id].lazy += w;
    no[id].Min += w;
    return;
  }
  if (no[id].lazy) pushdown(id);
  int mid = (l + r) >> 1;
  if (L <= mid) update(id << 1, l, mid, L, R, w);
  if (R > mid) update(id << 1 | 1, mid + 1, r, L, R, w);
  pushup(id);
}
long long query(int id, int l, int r, int L, int R) {
  if (l >= L && r <= R) return no[id].Min;
  if (no[id].lazy) pushdown(id);
  int mid = (l + r) >> 1;
  long long ans = inf;
  if (L <= mid) ans = query(id << 1, l, mid, L, R);
  if (R > mid) ans = min(ans, query(id << 1 | 1, mid + 1, r, L, R));
  return ans;
}
void Dfs(int u, long long valu) {
  update(1, 1, n, 1, n, valu);
  update(1, 1, n, in[u], out[u], -2 * valu);
  for (pair<pair<int, int>, int> x : vv[u]) {
    ans[x.second] = query(1, 1, n, x.first.first, x.first.second);
  }
  for (pair<int, long long> x : v[u]) {
    Dfs(x.first, x.second);
  }
  update(1, 1, n, 1, n, -valu);
  update(1, 1, n, in[u], out[u], 2 * valu);
}
int main() {
  int q, p, l, r;
  long long w;
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; i++) {
    scanf("%d%lld", &p, &w);
    v[p].push_back(pair<int, long long>(i, w));
  }
  dfs(1, 0ll);
  build(1, 1, n);
  for (int i = 1; i <= q; i++) {
    scanf("%d%d%d", &w, &l, &r);
    vv[w].push_back(make_pair(make_pair(l, r), i));
  }
  Dfs(1, 0);
  for (int i = 1; i <= q; i++) printf("%lld\n", ans[i]);
  return 0;
}
