#include <bits/stdc++.h>
using namespace std;
const int nsz = 5e5;
const long long inf = 0x3f3f3f3f3f3f3f3f;
int n, q;
int rt = 1, dfn[nsz + 5], siz[nsz + 5];
long long dis[nsz + 5], ans[nsz + 5];
vector<pair<int, int> > g[nsz + 5];
vector<pair<pair<int, int>, int> > qy[nsz + 5];
struct segment_tree {
  static int rt;
  int sz, ls[2 * nsz], rs[2 * nsz];
  long long mn[2 * nsz], del[2 * nsz];
  void init(long long *a, int &u = rt, int l = 1, int r = n) {
    u = ++sz;
    if (l == r) return (void)(mn[u] = a[l]);
    init(a, ls[u], l, ((l + r) >> 1)), init(a, rs[u], ((l + r) >> 1) + 1, r);
    mn[u] = min(mn[ls[u]], mn[rs[u]]);
  }
  void upd(int el, int er, int w, int u = rt, int l = 1, int r = n) {
    if (l >= el && r <= er) return (void)(mn[u] += w, del[u] += w);
    if (el <= ((l + r) >> 1)) upd(el, er, w, ls[u], l, ((l + r) >> 1));
    if (er > ((l + r) >> 1)) upd(el, er, w, rs[u], ((l + r) >> 1) + 1, r);
    mn[u] = min(mn[ls[u]], mn[rs[u]]) + del[u];
  }
  long long qry(int el, int er, int u = rt, int l = 1, int r = n) {
    if (l >= el && r <= er) return mn[u];
    long long res = inf;
    if (el <= ((l + r) >> 1)) res = qry(el, er, ls[u], l, ((l + r) >> 1));
    if (er > ((l + r) >> 1))
      res = min(res, qry(el, er, rs[u], ((l + r) >> 1) + 1, r));
    return res + del[u];
  }
};
int segment_tree::rt;
segment_tree tr;
void dfs(int u = rt) {
  static int t;
  bool lf = 1;
  dfn[u] = ++t, siz[u] = 1;
  for (int i = 0; i < g[u].size(); ++i) {
    int v = g[u][i].first, w = g[u][i].second;
    dis[v] = dis[u] + w;
    dfs(v), lf = 0;
    siz[u] += siz[v];
  }
  if (!lf) dis[u] = inf;
}
void solve(int u = rt) {
  for (int i = 0; i < qy[u].size(); ++i) {
    int id = qy[u][i].second;
    pair<int, int> &cur = qy[u][i].first;
    int l = cur.first, r = cur.second;
    ans[id] = tr.qry(cur.first, cur.second);
  }
  for (int i = 0; i < g[u].size(); ++i) {
    int v = g[u][i].first, w = g[u][i].second;
    tr.upd(1, n, w);
    tr.upd(dfn[v], dfn[v] + siz[v] - 1, -2 * w);
    solve(v);
    tr.upd(1, n, -w);
    tr.upd(dfn[v], dfn[v] + siz[v] - 1, 2 * w);
  }
}
void inline rearrage_by_dfn(long long *a) {
  long long b[nsz + 5];
  for (int i = 1; i <= n; ++i) b[dfn[i]] = a[i];
  for (int i = 1; i <= n; ++i) a[i] = b[i];
}
int main() {
  scanf("%d%d", &n, &q);
  for (int u = 2; u <= n; ++u) {
    int p, w;
    scanf("%d%d", &p, &w);
    g[p].push_back(make_pair(u, w));
  }
  for (int i = 1; i <= q; ++i) {
    int u, l, r;
    scanf("%d%d%d", &u, &l, &r);
    qy[u].push_back(make_pair(make_pair(l, r), i));
  }
  dfs();
  rearrage_by_dfn(dis);
  tr.init(dis);
  solve();
  for (int i = 1; i <= q; ++i) printf("%lld\n", ans[i]);
}
