#include <bits/stdc++.h>
using namespace std;
template <typename F, typename S>
ostream &operator<<(ostream &os, const pair<F, S> &p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  typename vector<T>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &v) {
  os << "[";
  typename set<T>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}
template <typename F, typename S>
ostream &operator<<(ostream &os, const map<F, S> &v) {
  os << "[";
  typename map<F, S>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << it->first << " = " << it->second;
  }
  return os << "]";
}
const long double PI = acos(-1.0);
const long long int mod = 1000000007;
const long long int inf = (long long int)1e16;
long long int power(long long int a, long long int b, long long int m = mod) {
  if (b == 0) return 1;
  if (b == 1) return (a % m);
  long long int x = power(a, b / 2, m);
  x = (x * x) % m;
  if (b % 2) x = (x * a) % m;
  return x;
}
long long int max(long long int a, long long int b) { return (a > b ? a : b); }
long long int min(long long int a, long long int b) { return (a < b ? a : b); }
const int N = 5e5 + 5;
const int M = 5e5 + 5;
struct query {
  long long int idx, l, r;
};
long long int n, q;
vector<pair<long long int, long long int>> adj[N];
vector<query> vv[N];
long long int tin[N], tout[N], cur = 1, eulertour[3 * N];
bool leaf[N];
long long int tree[4 * N], lazy[4 * N], wt[N], ans[N];
void dfs(int u, int p, long long int curw) {
  if (u != 1 && adj[u].size() == 1) leaf[u] = true;
  tin[u] = cur;
  eulertour[cur] = u;
  wt[u] = curw;
  cur++;
  for (auto it : adj[u]) {
    if (it.first == p) continue;
    dfs(it.first, u, curw + (long long int)it.second);
  }
  tout[u] = cur;
  eulertour[cur] = u;
  cur++;
}
void build(int node, int start, int end) {
  if (start == end) {
    if (leaf[eulertour[start]]) tree[node] = wt[eulertour[start]];
  } else {
    int mid = (start + end) / 2;
    build(2 * node, start, mid);
    build(2 * node + 1, mid + 1, end);
    tree[node] = min(tree[2 * node], tree[2 * node + 1]);
  }
}
void updateRange(int node, int start, int end, int l, int r,
                 long long int val) {
  if (lazy[node] != 0) {
    if (tree[node] < inf) tree[node] += lazy[node];
    if (start != end) {
      lazy[node * 2] += lazy[node];
      lazy[node * 2 + 1] += lazy[node];
    }
    lazy[node] = 0;
  }
  if (start > end or start > r or end < l) return;
  if (start >= l and end <= r) {
    if (tree[node] < inf) tree[node] += val;
    if (start != end) {
      lazy[node * 2] += val;
      lazy[node * 2 + 1] += val;
    }
    return;
  }
  int mid = (start + end) / 2;
  updateRange(node * 2, start, mid, l, r, val);
  updateRange(node * 2 + 1, mid + 1, end, l, r, val);
  tree[node] = min(tree[node * 2], tree[node * 2 + 1]);
}
long long int queryRange(int node, int start, int end, int l, int r) {
  if (start > end or start > r or end < l) return inf;
  if (lazy[node] != 0) {
    if (tree[node] < inf) tree[node] += lazy[node];
    if (start != end) {
      lazy[node * 2] += lazy[node];
      lazy[node * 2 + 1] += lazy[node];
    }
    lazy[node] = 0;
  }
  if (start >= l and end <= r) return tree[node];
  int mid = (start + end) / 2;
  long long int p1 = queryRange(node * 2, start, mid, l, r);
  long long int p2 = queryRange(node * 2 + 1, mid + 1, end, l, r);
  return min(p1, p2);
}
void dfs2(int u, int p, long long int curw) {
  for (auto it : vv[u]) {
    int l = it.l, r = it.r;
    ans[it.idx] = queryRange(1, 1, cur - 1, tin[l], tin[r]);
  }
  for (auto it : adj[u]) {
    if (it.first == p) continue;
    int v = it.first;
    updateRange(1, 1, cur - 1, tin[v], tout[v], -it.second);
    updateRange(1, 1, cur - 1, 1, tin[v] - 1, it.second);
    updateRange(1, 1, cur - 1, tout[v] + 1, cur - 1, it.second);
    dfs2(v, u, curw + it.second);
    updateRange(1, 1, cur - 1, tin[v], tout[v], it.second);
    updateRange(1, 1, cur - 1, 1, tin[v] - 1, -it.second);
    updateRange(1, 1, cur - 1, tout[v] + 1, cur - 1, -it.second);
  }
}
void solve() {
  fill(tree, tree + 4 * N, inf);
  cin >> n >> q;
  for (int i = 2; i <= n; i++) {
    int p, w;
    cin >> p >> w;
    adj[p].push_back({i, w});
    adj[i].push_back({p, w});
  }
  for (int i = 1; i <= n; i++) {
    sort(adj[i].begin(), adj[i].end());
  }
  dfs(1, -1, 0);
  build(1, 1, cur - 1);
  for (int i = 1; i <= q; i++) {
    int u, l, r;
    cin >> u >> l >> r;
    vv[u].push_back({i, l, r});
  }
  dfs2(1, -1, 0);
  for (int i = 1; i <= q; i++) cout << ans[i] << "\n";
  ;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1, num = 1;
  while (t--) {
    solve();
  }
  return 0;
}
