#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;
const long long INF_of_ll = 1e18;
vector<pair<int, int> > g[N];
vector<pair<pair<int, int>, int> > qy[N];
int n, q;
int id[N], pre[N], ind = 0;
int bg[N], ed[N], deg[N];
long long dis[N];
void dfs(int u) {
  id[u] = bg[u] = ++ind;
  pre[ind] = u;
  for (auto nxt : g[u]) {
    int v = nxt.first;
    dis[v] = dis[u] + nxt.second;
    dfs(v);
  }
  ed[u] = ind;
}
long long val[N], tag[N];
void pushup(int t) { val[t] = min(val[(t << 1)], val[(t << 1 | 1)]); }
void pushnow(int t, long long vl) {
  val[t] += vl;
  tag[t] += vl;
}
void pushdown(int t) {
  if (tag[t]) {
    pushnow((t << 1), tag[t]);
    pushnow((t << 1 | 1), tag[t]);
    tag[t] = 0;
  }
}
void build(int t, int l, int r) {
  if (l == r) {
    val[t] = dis[pre[l]];
    return;
  }
  int mid = (l + r) >> 1;
  build((t << 1), l, mid);
  build((t << 1 | 1), mid + 1, r);
  pushup(t);
}
void modify(int t, int l, int r, int ql, int qr, long long vl) {
  if (ql <= l && r <= qr) {
    pushnow(t, vl);
    return;
  }
  pushdown(t);
  int mid = (l + r) >> 1;
  if (ql <= mid) modify((t << 1), l, mid, ql, qr, vl);
  if (qr > mid) modify((t << 1 | 1), mid + 1, r, ql, qr, vl);
  pushup(t);
}
long long query(int t, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) return val[t];
  pushdown(t);
  int mid = (l + r) >> 1;
  long long ans = INF_of_ll;
  if (ql <= mid) ans = min(ans, query((t << 1), l, mid, ql, qr));
  if (qr > mid) ans = min(ans, query((t << 1 | 1), mid + 1, r, ql, qr));
  return ans;
}
long long ans[N];
void work(int u) {
  for (auto cur : qy[u])
    ans[cur.second] = query(1, 1, n, cur.first.first, cur.first.second);
  for (auto nxt : g[u]) {
    int v = nxt.first;
    modify(1, 1, n, 1, n, nxt.second);
    modify(1, 1, n, bg[v], ed[v], -2 * nxt.second);
    work(v);
    modify(1, 1, n, 1, n, -nxt.second);
    modify(1, 1, n, bg[v], ed[v], 2 * nxt.second);
  }
}
int main() {
  scanf("%d %d", &n, &q);
  for (int u = 2; u <= n; u++) {
    int v, w;
    scanf("%d %d", &v, &w);
    g[v].push_back(pair<int, int>(u, w));
    deg[u]++, deg[v]++;
  }
  for (int i = 1; i <= q; i++) {
    int v, l, r;
    scanf("%d %d %d", &v, &l, &r);
    qy[v].push_back(make_pair(make_pair(l, r), i));
  }
  dfs(1);
  build(1, 1, n);
  for (int i = 1; i <= n; i++)
    if (deg[i] != 1) modify(1, 1, n, id[i], id[i], INF_of_ll);
  work(1);
  for (int i = 1; i <= q; i++) printf("%lld\n", ans[i]);
  return 0;
}
