#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
static char buf[1 << 25], *s = buf;
inline void read(int& x) {
  x = 0;
  for (; !isdigit(*s); ++s)
    ;
  while (isdigit(*s)) x = x * 10 + (*s++ ^ '0');
}
static char obuf[1 << 25], *t = obuf;
inline void put(long long x) {
  static int st[233], top = 0;
  do {
    st[++top] = x % 10;
    x /= 10;
  } while (x);
  while (top) *t++ = st[top--] ^ '0';
  *t++ = ' ';
}
template <class T>
inline void cmax(T& x, const T& y) {
  if (x < y) x = y;
}
template <class T>
inline void cmin(T& x, const T& y) {
  if (x > y) x = y;
}
int n, m;
const int maxn = 5e5 + 55;
int rt[maxn];
struct SMT {
  long long val[maxn * 40];
  int ls[maxn * 40], rs[maxn * 40], cnt;
  SMT() { cnt = 0, memset(val, 0x3f, sizeof(val)); }
  void upd(int& p, int l, int r, int x, long long v) {
    if (!p) p = ++cnt;
    if (l == r) {
      cmin(val[p], v);
      return;
    }
    int mid = l + r >> 1;
    if (x <= mid)
      upd(ls[p], l, mid, x, v);
    else
      upd(rs[p], mid + 1, r, x, v);
    val[p] = min(val[ls[p]], val[rs[p]]);
  }
  long long qry(int p, int a, int b, int l, int r) {
    if (!p) return 1e18;
    if (a <= l && r <= b) return val[p];
    int mid = l + r >> 1;
    long long ans = 1e18;
    if (a <= mid) cmin(ans, qry(ls[p], a, b, l, mid));
    if (b > mid) cmin(ans, qry(rs[p], a, b, mid + 1, r));
    return ans;
  }
} smt;
struct edge {
  int v, nxt, w;
} e[maxn << 1];
int cnt = 0, head[maxn];
void add(int u, int v, int w) {
  e[++cnt] = {v, head[u], w}, head[u] = cnt;
  e[++cnt] = {u, head[v], w}, head[v] = cnt;
}
struct Tree {
  int f[maxn][21], fa[maxn], dep[maxn];
  long long len[maxn];
  void dfs(int u) {
    dep[u] = dep[fa[u]] + 1;
    for (int i = head[u]; i; i = e[i].nxt) {
      int v = e[i].v;
      if (v ^ fa[u]) {
        fa[v] = u, len[v] = len[u] + e[i].w;
        dfs(v);
      }
    }
  }
  void solve() {
    dfs(1);
    for (int i = 1; i <= n; i++) f[i][0] = fa[i];
    for (int j = 1; j <= 20; j++) {
      for (int i = 1; i <= n; i++) f[i][j] = f[f[i][j - 1]][j - 1];
    }
  }
  int lca(int x, int y) {
    if (dep[x] < dep[y]) x ^= y ^= x ^= y;
    for (int i = 20; ~i; i--)
      if (dep[f[x][i]] >= dep[y]) x = f[x][i];
    if (x == y) return x;
    for (int i = 20; ~i; i--)
      if (f[x][i] ^ f[y][i]) x = f[x][i], y = f[y][i];
    return f[x][0];
  }
  long long dis(int x, int y) {
    return len[x] + len[y] - (len[lca(x, y)] << 1);
  }
} tr;
struct NewTree {
  int sz[maxn], mx[maxn], vis[maxn], fa[maxn];
  vector<int> g[maxn];
  int rt, tot;
  NewTree() { mx[rt = 0] = 1e9; }
  void getrt(int u, int fa) {
    sz[u] = 1, mx[u] = 0;
    for (int i = head[u]; i; i = e[i].nxt) {
      int v = e[i].v;
      if (v ^ fa && !vis[v]) {
        getrt(v, u);
        sz[u] += sz[v], cmax(mx[u], sz[v]);
      }
    }
    cmax(mx[u], tot - sz[u]);
    if (mx[u] < mx[rt]) {
      rt = u;
    }
  }
  void solve(int u) {
    vis[u] = 1;
    const int now = tot;
    for (int i = head[u]; i; i = e[i].nxt) {
      int v = e[i].v;
      if (!vis[v]) {
        rt = 0, tot = (sz[v] > sz[u]) ? (now - sz[u]) : sz[v];
        getrt(v, u), g[u].emplace_back(rt), fa[rt] = u, solve(rt);
      }
    }
  }
  void upd(int x, int val) {
    int now = x;
    while (x) {
      smt.upd(::rt[x], 1, n, val, tr.dis(now, x));
      x = fa[x];
    }
  }
  long long qry(int x, int l, int r) {
    int now = x;
    long long ans = 1e18;
    while (x) {
      cmin(ans, tr.dis(now, x) + smt.qry(::rt[x], l, r, 1, n));
      x = fa[x];
    }
    return ans;
  }
} nt;
signed main() {
  buf[fread(buf, 1, 1 << 26, stdin)] = '\n';
  read(n), read(m);
  std::vector<int> deg(n + 1, 0);
  for (int i = 2; i <= n; i++) {
    int father, w;
    read(father), read(w);
    add(father, i, w);
    deg[father]++;
    deg[i]++;
  }
  tr.solve(), nt.tot = n, nt.getrt(1, 0), nt.solve(nt.rt);
  for (int i = 1; i <= n; i++)
    if (deg[i] == 1) {
      nt.upd(i, i);
    }
  while (m--) {
    int x, l, r;
    read(x), read(l), read(r);
    long long ans = nt.qry(x, l, r);
    put(ans);
  }
  fwrite(obuf, 1, t - obuf, stdout);
  return 0;
}
