#include <bits/stdc++.h>
using namespace std;
namespace FastIO {
inline void read(int &num) {
  num = 0;
  char c;
  bool neg = false;
  do {
    c = getchar();
  } while (!isdigit(c) && c != '-');
  if (c == '-') c = getchar(), neg = true;
  while (isdigit(c)) num = num * 10 + c - '0', c = getchar();
  if (neg) num = -num;
}
inline void write(long long num) {
  if (num < 0)
    write(-num);
  else {
    if (num > 9) write(num / 10);
    putchar(num % 10 + '0');
  }
}
}  // namespace FastIO
using namespace FastIO;
struct query {
  int l, r, id;
};
const int N = 5e5 + 5;
const long long inf = 1e15;
int n, q;
int arr[N];
pair<int, int> range[N];
vector<pair<int, int> > adj[N];
vector<query> ques[N];
long long ans[N], dep[N];
int Time;
void buildEulerTour(int u, int pu = -1) {
  bool isLeaf = true;
  range[u].first = Time + 1;
  for (auto it : adj[u]) {
    int v = it.first, w = it.second;
    if (v == pu) continue;
    isLeaf = false;
    dep[v] = dep[u] + w;
    buildEulerTour(v, u);
  }
  if (isLeaf) arr[++Time] = u;
  range[u].second = Time;
}
struct IntervalTree {
  struct dataNode {
    long long val, lazy;
  };
  dataNode node[4 * N];
  void push(int id) {
    int t = node[id].lazy;
    node[id + id].val += t;
    node[id + id].lazy += t;
    node[id + id + 1].val += t;
    node[id + id + 1].lazy += t;
    node[id].lazy = 0;
  }
  void update(int l, int r, long long w, int id = 1, int low = 1,
              int high = Time) {
    if (l > r) return;
    if (low > r || high < l) return;
    if (l <= low && high <= r) {
      node[id].val += w;
      node[id].lazy += w;
      return;
    }
    push(id);
    int mid = (low + high) >> 1;
    update(l, r, w, id + id, low, mid);
    update(l, r, w, id + id + 1, mid + 1, high);
    node[id].val = min(node[id + id].val, node[id + id + 1].val);
  }
  long long get(int l, int r, int id = 1, int low = 1, int high = Time) {
    if (low > r || high < l) return inf;
    if (l <= low && high <= r) return node[id].val;
    push(id);
    int mid = (low + high) >> 1;
    long long x = get(l, r, id + id, low, mid);
    long long y = get(l, r, id + id + 1, mid + 1, high);
    return min(x, y);
  }
} IT;
void calculate(int u, int pu = -1) {
  for (auto it : ques[u]) {
    int _l = it.l, _r = it.r, id = it.id;
    int l = lower_bound(arr + 1, arr + 1 + Time, _l) - arr;
    int r = upper_bound(arr + 1, arr + 1 + Time, _r) - arr - 1;
    ans[id] = IT.get(l, r);
  }
  for (auto it : adj[u]) {
    int v = it.first, w = it.second;
    if (v == pu) continue;
    IT.update(1, range[v].first - 1, w);
    IT.update(range[v].second + 1, Time, w);
    IT.update(range[v].first, range[v].second, -w);
    calculate(v, u);
    IT.update(1, range[v].first - 1, -w);
    IT.update(range[v].second + 1, Time, -w);
    IT.update(range[v].first, range[v].second, w);
  }
}
int main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if (fopen("main.in", "r")) freopen("main.in", "r", stdin);
  read(n), read(q);
  for (int i = 2; i <= n; i++) {
    int p, w;
    read(p), read(w);
    adj[p].push_back({i, w});
  }
  for (int i = 1; i <= q; i++) {
    int u, l, r;
    read(u), read(l), read(r);
    ques[u].push_back({l, r, i});
  }
  for (int i = 1; i <= n; i++) sort(adj[i].begin(), adj[i].end());
  buildEulerTour(1);
  for (int i = 1; i <= Time; i++) IT.update(i, i, dep[arr[i]]);
  calculate(1);
  for (int i = 1; i <= q; i++) write(ans[i]), puts("");
  return 0;
}
