#include <bits/stdc++.h>
using namespace std;
inline int gi() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 3) + (x << 1) + ch - 48;
    ch = getchar();
  }
  return x * f;
}
template <typename T>
inline bool Max(T &a, T b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T>
inline bool Min(T &a, T b) {
  return a > b ? a = b, 1 : 0;
}
const int N = 5e5 + 7;
const long long inf = 1e16;
int n, q;
int R[N];
long long mi[N << 2], adv[N << 2], dis[N], ans[N];
struct data {
  int id, l, r;
};
vector<pair<int, int> > G[N];
vector<data> Q[N];
void st1(int o, long long v) {
  adv[o] += v;
  mi[o] += v;
}
void pushdown(int o) {
  if (!adv[o]) return;
  st1(o << 1, adv[o]);
  st1(o << 1 | 1, adv[o]);
  adv[o] = 0;
}
void pushup(int o) { mi[o] = min(mi[o << 1], mi[o << 1 | 1]); }
void modify(int L, int R, int l, int r, int o, long long v) {
  if (L <= l && r <= R) {
    st1(o, v);
    return;
  }
  pushdown(o);
  int mid = l + r >> 1;
  if (L <= mid) modify(L, R, l, mid, o << 1, v);
  if (R > mid) modify(L, R, mid + 1, r, o << 1 | 1, v);
  pushup(o);
}
long long query(int L, int R, int l, int r, int o) {
  if (L <= l && r <= R) return mi[o];
  pushdown(o);
  int mid = l + r >> 1;
  if (R <= mid) return query(L, R, l, mid, o << 1);
  if (L > mid) return query(L, R, mid + 1, r, o << 1 | 1);
  return min(query(L, R, l, mid, o << 1), query(L, R, mid + 1, r, o << 1 | 1));
}
void dfs1(int u) {
  sort(G[u].begin(), G[u].end());
  R[u] = u;
  for (auto v : G[u]) {
    dis[v.first] = dis[u] + v.second;
    dfs1(v.first);
    R[u] = R[v.first];
  }
  if (G[u].empty())
    modify(u, u, 1, n, 1, dis[u]);
  else
    modify(u, u, 1, n, 1, inf);
}
void dfs2(int u) {
  for (auto v : G[u]) {
    modify(v.first, R[v.first], 1, n, 1, -2 * v.second);
    dfs2(v.first);
    modify(v.first, R[v.first], 1, n, 1, 2 * v.second);
  }
  for (auto v : Q[u]) {
    ans[v.id] = query(v.l, v.r, 1, n, 1) + dis[u];
  }
}
int main() {
  n = gi(), q = gi();
  for (int i = 2; i <= n; ++i) {
    int fa = gi(), w = gi();
    G[fa].push_back(make_pair(i, w));
  }
  dfs1(1);
  for (int i = 1; i <= q; ++i) {
    int v = gi(), l = gi(), r = gi();
    Q[v].push_back((data){i, l, r});
  }
  dfs2(1);
  for (int i = 1; i <= q; ++i) printf("%lld\n", ans[i]);
  return 0;
}
