#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10;
const long long inf = 1e18;
int n, q;
int p[maxn];
int w[maxn];
vector<int> G[maxn];
vector<int> Q[maxn];
int id[maxn];
int out[maxn];
int rev[maxn];
int tim;
long long init[maxn];
int v[maxn];
int l[maxn];
int r[maxn];
long long ans[maxn];
long long tree[maxn * 4];
long long lazy[maxn * 4];
void dfs(int u, long long dis) {
  dis += w[u];
  id[u] = ++tim;
  rev[tim] = u;
  init[u] = dis;
  for (int v : G[u]) {
    dfs(v, dis);
  }
  out[u] = tim;
}
void pushup(int rt) { tree[rt] = min(tree[rt << 1], tree[rt << 1 | 1]); }
void pushdown(int rt) {
  if (lazy[rt]) {
    lazy[rt << 1] += lazy[rt];
    lazy[rt << 1 | 1] += lazy[rt];
    tree[rt << 1] += lazy[rt];
    tree[rt << 1 | 1] += lazy[rt];
    lazy[rt] = 0;
  }
}
void build(int rt, int l, int r) {
  if (l >= r) {
    tree[rt] = init[l];
    return;
  }
  int m = (l + r) >> 1;
  build(rt << 1, l, m);
  build(rt << 1 | 1, m + 1, r);
  pushup(rt);
}
void update(int rt, int l, int r, int L, int R, int val) {
  if (L <= l && r <= R) {
    tree[rt] += val;
    lazy[rt] += val;
    return;
  }
  pushdown(rt);
  int m = (l + r) >> 1;
  if (L <= m) {
    update(rt << 1, l, m, L, R, val);
  }
  if (R > m) {
    update(rt << 1 | 1, m + 1, r, L, R, val);
  }
  pushup(rt);
}
long long query(int rt, int l, int r, int L, int R) {
  if (L <= l && r <= R) {
    return tree[rt];
  }
  pushdown(rt);
  int m = (l + r) >> 1;
  long long ret = inf;
  if (L <= m) {
    ret = min(ret, query(rt << 1, l, m, L, R));
  }
  if (R > m) {
    ret = min(ret, query(rt << 1 | 1, m + 1, r, L, R));
  }
  return ret;
}
void dfs2(int u, long long delta = 0) {
  for (int i : Q[u]) {
    ans[i] = query(1, 1, n, l[i], r[i]) + delta;
  }
  for (int v : G[u]) {
    update(1, 1, n, id[v], out[v], -2 * w[v]);
    dfs2(v, delta + w[v]);
    update(1, 1, n, id[v], out[v], 2 * w[v]);
  }
}
int main() {
  scanf("%d %d", &n, &q);
  for (int i = 2; i <= n; ++i) {
    scanf("%d %d", &p[i], &w[i]);
    G[p[i]].push_back(i);
  }
  for (int i = 0; i < q; ++i) {
    scanf("%d %d %d", &v[i], &l[i], &r[i]);
    Q[v[i]].push_back(i);
  }
  dfs(1, 0);
  for (int i = 1; i <= n; ++i) {
    if (!G[i].empty()) {
      init[i] = inf;
    }
  }
  build(1, 1, n);
  dfs2(1);
  for (int i = 0; i < q; ++i) {
    printf("%lld\n", ans[i]);
  }
  return 0;
}
