#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const int maxn = 5e5 + 10;
const int maxq = 5e5 + 10;
struct edge {
  int v, w;
  edge(int v = 0, int w = 0) : v(v), w(w) {}
};
vector<edge> adj[maxn];
int r[maxn];
long long dis[maxn];
void dfs(int u, int up, long long d) {
  if (adj[u].size() == 1) dis[u] = d;
  r[u] = u;
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i].v, w = adj[u][i].w;
    if (v == up) continue;
    dfs(v, u, d + w);
    r[u] = max(r[u], r[v]);
  }
}
struct queryn {
  int id, l, r;
  queryn(int id = 0, int l = 0, int r = 0) : id(id), l(l), r(r) {}
};
vector<queryn> que[maxn];
struct node {
  long long lt, x, ans;
  node *ls, *rs;
} * root;
node* build(int l, int r) {
  static node pool[maxn * 2];
  static int ind = 0;
  node* cur = pool + ind++;
  if (l == r) {
    cur->x = cur->ans = dis[l];
    return cur;
  }
  int mid = (l + r) >> 1;
  cur->ls = build(l, mid);
  cur->rs = build(mid + 1, r);
  cur->ans = min(cur->ls->ans, cur->rs->ans);
  return cur;
}
void pushdown(node*& cur, int l, int r) {
  if (cur->lt) {
    if (cur->ls) {
      cur->ls->lt += cur->lt;
      cur->ls->ans += cur->lt;
    }
    if (cur->rs) {
      cur->rs->lt += cur->lt;
      cur->rs->ans += cur->lt;
    }
  }
  cur->lt = 0;
}
long long query(node* cur, int stdl, int stdr, int l, int r) {
  if (l <= stdl && stdr <= r) return cur->ans;
  pushdown(cur, stdl, stdr);
  int mid = (stdl + stdr) >> 1;
  long long ans = inf;
  if (l <= mid) ans = query(cur->ls, stdl, mid, l, r);
  if (mid < r) ans = min(ans, query(cur->rs, mid + 1, stdr, l, r));
  return ans;
}
void update(node*& cur, int stdl, int stdr, int l, int r, long long x) {
  if (l <= stdl && stdr <= r) {
    cur->lt += x;
    cur->ans += x;
    return;
  }
  pushdown(cur, stdl, stdr);
  int mid = (stdl + stdr) >> 1;
  if (l <= mid) update(cur->ls, stdl, mid, l, r, x);
  if (mid < r) update(cur->rs, mid + 1, stdr, l, r, x);
  cur->ans = min(cur->ls->ans, cur->rs->ans);
}
int n;
long long ans[maxq];
void cal(int u, int up) {
  for (int i = 0; i < que[u].size(); i++) {
    int id = que[u][i].id, l = que[u][i].l, r = que[u][i].r;
    ans[id] = query(root, 1, n, l, r);
  }
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i].v, w = adj[u][i].w;
    if (v == up) continue;
    update(root, 1, n, v, r[v], -w);
    update(root, 1, n, 1, v - 1, w);
    if (r[v] != n) update(root, 1, n, r[v] + 1, n, w);
    cal(v, u);
    update(root, 1, n, v, r[v], w);
    update(root, 1, n, 1, v - 1, -w);
    if (r[v] != n) update(root, 1, n, r[v] + 1, n, -w);
  }
}
int main() {
  int q;
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; i++) {
    int v, w;
    scanf("%d%d", &v, &w);
    adj[i].push_back(edge(v, w));
    adj[v].push_back(edge(i, w));
  }
  for (int i = 1; i <= q; i++) {
    int v, l, r;
    scanf("%d%d%d", &v, &l, &r);
    que[v].push_back(queryn(i, l, r));
  }
  for (int i = 1; i <= n; i++) dis[i] = inf;
  dfs(1, 1, 0);
  root = build(1, n);
  cal(1, 1);
  for (int i = 1; i <= q; i++) printf("%lld\n", ans[i]);
  return 0;
}
