#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFF = 0x3f3f3f3f3f3f3f3fll;
const long long M = 1e9 + 7;
const long long maxn = 1e6 + 107;
const double pi = acos(-1.0);
const double eps = 0.0000000001;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
template <typename T>
inline void pr2(T x, int k = 64) {
  long long i;
  for (i = 0; i < k; i++) fprintf(stderr, "%d", (x >> i) & 1);
  putchar(' ');
}
template <typename T>
inline void add_(T &A, int B, long long MOD = M) {
  A += B;
  (A >= MOD) && (A -= MOD);
}
template <typename T>
inline void mul_(T &A, long long B, long long MOD = M) {
  A = (A * B) % MOD;
}
template <typename T>
inline void mod_(T &A, long long MOD = M) {
  A %= MOD;
  A += MOD;
  A %= MOD;
}
template <typename T>
inline void max_(T &A, T B) {
  (A < B) && (A = B);
}
template <typename T>
inline void min_(T &A, T B) {
  (A > B) && (A = B);
}
template <typename T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
template <typename T>
inline T powMM(T a, T b) {
  T ret = 1;
  for (; b; b >>= 1ll, a = (long long)a * a % M)
    if (b & 1) ret = (long long)ret * a % M;
  return ret;
}
int startTime;
void startTimer() { startTime = clock(); }
void printTimer() {
  fprintf(stderr, "/--- Time: %ld milliseconds ---/\n", clock() - startTime);
}
int n, m, q;
char str[maxn];
long long MIN[maxn], lazy[maxn];
void update(int x, int l, int r, long long val, int L, int R) {
  if (l <= L && R <= r) {
    MIN[x] += val;
    lazy[x] += val;
    return;
  }
  int mid = (L + R) / 2;
  if (l <= mid) update(x << 1, l, r, val, L, mid);
  if (mid < r) update(x << 1 | 1, l, r, val, mid + 1, R);
  MIN[x] = min(MIN[x << 1], MIN[x << 1 | 1]) + lazy[x];
}
long long query(int x, int l, int r, int L, int R) {
  if (l <= L && R <= r) return MIN[x];
  long long ret = INFF, mid = (L + R) / 2;
  if (l <= mid) ret = min(ret, query(x << 1, l, r, L, mid));
  if (mid < r) ret = min(ret, query(x << 1 | 1, l, r, mid + 1, R));
  return ret + lazy[x];
}
vector<pair<int, int> > edge[maxn];
int in[maxn], out[maxn], tot;
void dfs1(int x, long long dep) {
  in[x] = ++tot;
  for (pair<int, int> e : edge[x]) dfs1(e.first, dep + e.second);
  if (!edge[x].size())
    update(1, x, x, dep, 1, n);
  else
    update(1, x, x, INFF, 1, n);
  out[x] = tot;
}
long long ans[maxn];
vector<pair<pair<int, int>, int> > queries[maxn];
void dfs2(int x) {
  for (auto now : queries[x])
    ans[now.second] = query(1, now.first.first, now.first.second, 1, n);
  for (pair<int, int> e : edge[x]) {
    int v = e.first, l = e.second;
    update(1, 1, n, l, 1, n);
    update(1, in[v], out[v], -2 * l, 1, n);
    dfs2(v);
    update(1, 1, n, -l, 1, n);
    update(1, in[v], out[v], 2 * l, 1, n);
  }
}
int main() {
  int i;
  scanf("%d%d", &n, &q);
  for (i = 2; i <= n; i++) {
    int f, l;
    scanf("%d%d", &f, &l);
    edge[f].push_back(make_pair(i, l));
  }
  dfs1(1, 0);
  for (i = 1; i <= q; i++) {
    int l, r, v;
    scanf("%d%d%d", &v, &l, &r);
    queries[v].push_back(make_pair(make_pair(l, r), i));
  }
  dfs2(1);
  for (i = 1; i <= q; i++) printf("%lld\n", ans[i]);
}
