#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void Cin(T& x) {
  char c;
  T sign = 1;
  x = 0;
  for (c = getchar(); c < '0' || c > '9'; c = getchar())
    if (c == '-') sign = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  x *= sign;
}
template <typename T>
inline T Min(const T& a, const T& val) {
  return val < a ? val : a;
}
template <typename T>
inline void Out(T x) {
  if (x > 9) Out(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
inline void Cout(T x, char c) {
  if (x < 0) putchar('-');
  x = abs(x);
  Out(x);
  putchar(c);
}
template <typename T, typename... Args>
inline void Cin(T& a, Args&... args) {
  Cin(a);
  Cin(args...);
}
template <typename T, typename... Args>
inline void Cout(T a, char c, Args... args) {
  Cout(a, c);
  Cout(args...);
}
const int N = 5e5 + 1;
const long long inf = (long long)1e15;
int n, Q, p[N], w[N], id[N], l[N << 2], h[N << 2], last[N], cur = 0;
long long st[N << 2], lazy[N << 2], dis[N], res[N];
struct T {
  int l, r, id;
  inline T(int l = 0, int r = 0, int id = 0) : l(l), r(r), id(id) {}
};
vector<T> q[N];
vector<int> a[N];
void Build(int x, int low, int high) {
  l[x] = low, h[x] = high;
  if (low == high) {
    st[x] = (a[low].empty() ? dis[low] : inf);
    return;
  }
  int mid = (low + high) >> 1;
  Build(x << 1, low, mid);
  Build(x << 1 | 1, mid + 1, high);
  st[x] = Min(st[x << 1], st[x << 1 | 1]);
}
inline void Down(const int& x) {
  if (lazy[x]) {
    st[x] += lazy[x];
    if (l[x] != h[x]) {
      lazy[x << 1] += lazy[x];
      lazy[x << 1 | 1] += lazy[x];
    }
    lazy[x] = 0;
  }
}
void Update(int x, int low, int high, const int& v) {
  Down(x);
  if (l[x] > high || h[x] < low) return;
  if (l[x] >= low && h[x] <= high) {
    lazy[x] += v;
    Down(x);
    return;
  }
  Update(x << 1, low, high, v);
  Update(x << 1 | 1, low, high, v);
  st[x] = Min(st[x << 1], st[x << 1 | 1]);
}
long long Query(int x, int low, int high) {
  Down(x);
  if (l[x] > high || h[x] < low) return inf;
  if (l[x] >= low && h[x] <= high) return st[x];
  return Min(Query(x << 1, low, high), Query(x << 1 | 1, low, high));
}
void Build(int u) {
  id[u] = ++cur;
  for (int& v : a[u]) {
    dis[v] = dis[u] + w[v];
    Build(v);
  }
  last[u] = cur;
}
void DFS(int u) {
  for (T& t : q[u]) res[t.id] = dis[u] + Query(1, t.l, t.r);
  for (int& v : a[u]) {
    Update(1, id[v], last[v], -2 * w[v]);
    DFS(v);
    Update(1, id[v], last[v], 2 * w[v]);
  }
}
void Enter() {
  Cin(n, Q);
  for (int i = 2; i <= n; ++i) {
    Cin(p[i], w[i]);
    a[p[i]].emplace_back(i);
  }
  Build(1);
  int u, l, r;
  for (int i = 1; i <= Q; ++i) {
    Cin(u, l, r);
    q[u].emplace_back(l, r, i);
  }
}
void Solve() {
  Build(1, 1, n);
  DFS(1);
  for (int i = 1; i <= Q; ++i) Cout(res[i], '\n');
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  Enter();
  Solve();
  return 0;
}
