#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  x = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
}
struct edge {
  int v, w;
  inline edge(int v = 0, int w = 0) : v(v), w(w) {}
};
vector<edge> adj[500003];
vector<int> qwq[500003];
int fa[500003], dep[500003], size[500003], pfx[500003], L[500003], R[500003];
long long dis[500003], a[500003], ans[500003];
int n, q;
struct Segment_Tree {
  long long mn[500003 << 2], tag[500003 << 2];
  inline void pushdown(int u, int l, int r) {
    if (!tag[u]) return;
    tag[(u << 1)] += tag[u], tag[(u << 1 | 1)] += tag[u];
    mn[(u << 1)] += tag[u], mn[(u << 1 | 1)] += tag[u];
    tag[u] = 0;
  }
  void build(int l, int r, int u) {
    if (l == r) {
      mn[u] = a[l];
      return;
    }
    build(l, ((l + r) >> 1), (u << 1));
    build(((l + r) >> 1) + 1, r, (u << 1 | 1));
    mn[u] = min(mn[(u << 1)], mn[(u << 1 | 1)]);
  }
  void modify(int nl, int nr, int l, int r, int u, long long k) {
    if (nl <= l && r <= nr) {
      mn[u] += k, tag[u] += k;
      return;
    }
    pushdown(u, l, r);
    if (nl <= ((l + r) >> 1)) modify(nl, nr, l, ((l + r) >> 1), (u << 1), k);
    if (nr > ((l + r) >> 1))
      modify(nl, nr, ((l + r) >> 1) + 1, r, (u << 1 | 1), k);
    mn[u] = min(mn[(u << 1)], mn[(u << 1 | 1)]);
  }
  long long query(int nl, int nr, int l, int r, int u) {
    if (nl <= l && r <= nr) return mn[u];
    long long res = 0x3f3f3f3f3f3f3f3fll;
    pushdown(u, l, r);
    if (nl <= ((l + r) >> 1))
      res = min(res, query(nl, nr, l, ((l + r) >> 1), (u << 1)));
    if (nr > ((l + r) >> 1))
      res = min(res, query(nl, nr, ((l + r) >> 1) + 1, r, (u << 1 | 1)));
    return res;
  }
} T;
void dfs1(int u, int f) {
  size[u] = 1;
  fa[u] = f;
  dep[u] = dep[f] + 1;
  pfx[u] = u;
  int v, l = adj[u].size();
  for (int i = 0; i < l; ++i) {
    v = adj[u][i].v;
    dis[v] = dis[u] + adj[u][i].w;
    dfs1(v, u);
    size[u] += size[v];
    pfx[u] = max(pfx[u], pfx[v]);
  }
}
void dfs2(int u) {
  int v, w, l = qwq[u].size();
  for (register int i = 0; i < l; ++i) {
    v = qwq[u][i];
    ans[v] = T.query(L[v], R[v], 1, n, 1);
  }
  l = adj[u].size();
  for (int i = 0; i < l; ++i) {
    v = adj[u][i].v;
    w = adj[u][i].w;
    T.modify(1, n, 1, n, 1, w);
    T.modify(v, pfx[v], 1, n, 1, -(w << 1));
    dfs2(v);
    T.modify(1, n, 1, n, 1, -w);
    T.modify(v, pfx[v], 1, n, 1, w << 1);
  }
}
int main() {
  memset(T.mn, 0x3f, sizeof(T.mn));
  int v, w, l, r;
  read(n), read(q);
  for (register int i = 2; i <= n; ++i) {
    read(v), read(w);
    adj[v].push_back(edge(i, w));
  }
  dfs1(1, 0);
  for (register int i = 1; i <= n; ++i)
    a[i] = i == pfx[i] ? dis[i] : 0x3f3f3f3f3f3f3f3fll;
  T.build(1, n, 1);
  for (register int i = 1; i <= q; ++i) {
    read(v), read(L[i]), read(R[i]);
    qwq[v].push_back(i);
  }
  dfs2(1);
  for (register int i = 1; i <= q; ++i) printf("%I64d\n", ans[i]);
  return 0;
}
