#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
struct query {
  int l, r, ind;
};
int n, q, out[N];
long long a[N], ans[N];
vector<pair<int, int>> g[N];
vector<query> queries[N];
int dfs(int node, long long dist) {
  out[node] = node;
  for (auto &i : g[node])
    out[node] = max(out[node], dfs(i.first, dist + i.second));
  if (g[node].empty())
    a[node] = dist;
  else
    a[node] = 1e16;
  return out[node];
}
long long seg[4 * N], lazy[4 * N];
void build(int node, int s, int e) {
  if (s == e) {
    seg[node] = a[s];
    return;
  }
  int mid = s + e >> 1;
  build(node << 1, s, mid);
  build(node << 1 | 1, mid + 1, e);
  seg[node] = min(seg[node << 1], seg[node << 1 | 1]);
}
void prop(int node, int s, int e) {
  if (lazy[node]) {
    seg[node] += lazy[node];
    if (s != e) {
      lazy[node << 1] += lazy[node];
      lazy[node << 1 | 1] += lazy[node];
    }
    lazy[node] = 0;
  }
}
void update(int node, int s, int e, int l, int r, long long val) {
  prop(node, s, e);
  if (e < l || s > r) return;
  if (l <= s && e <= r) {
    lazy[node] += val;
    prop(node, s, e);
    return;
  }
  int mid = s + e >> 1;
  update(node << 1, s, mid, l, r, val);
  update(node << 1 | 1, mid + 1, e, l, r, val);
  seg[node] = min(seg[node << 1], seg[node << 1 | 1]);
}
long long query(int node, int s, int e, int l, int r) {
  prop(node, s, e);
  if (e < l || s > r) return 1e16;
  if (l <= s && e <= r) return seg[node];
  int mid = s + e >> 1;
  return min(query(node << 1, s, mid, l, r),
             query(node << 1 | 1, mid + 1, e, l, r));
}
void solve(int node) {
  for (auto &i : queries[node]) {
    int l = i.l, r = i.r, ind = i.ind;
    ans[ind] = query(1, 1, n, l, r);
  }
  for (auto &i : g[node]) {
    update(1, 1, n, 1, n, i.second);
    update(1, 1, n, i.first, out[i.first], -2 * i.second);
    solve(i.first);
    update(1, 1, n, 1, n, -i.second);
    update(1, 1, n, i.first, out[i.first], 2 * i.second);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q;
  for (int i = 2; i <= n; i++) {
    int p, w;
    cin >> p >> w;
    g[p].push_back({i, w});
  }
  for (int i = 1; i <= q; i++) {
    int u, l, r;
    cin >> u >> l >> r;
    queries[u].push_back({l, r, i});
  }
  dfs(1, 0);
  build(1, 1, n);
  solve(1);
  for (int i = 1; i <= q; i++) cout << ans[i] << '\n';
  return 0;
}
