#include <bits/stdc++.h>
using namespace std;
vector<pair<int, long long int> > adj[500010];
int id[500010], cnt = 0;
const long long int inf = 1e18;
int n;
vector<pair<int, pair<int, int> > > Q[500010];
long long int tree[4 * 500010], lazy[4 * 500010];
void push(int node, int start, int end) {
  tree[node] += lazy[node];
  if (start != end) {
    lazy[2 * node] += lazy[node];
    lazy[2 * node + 1] += lazy[node];
  }
  lazy[node] = 0;
}
void update(int node, int start, int end, int l, int r, long long int x) {
  push(node, start, end);
  if (r < start || end < l) return;
  if (start >= l && end <= r) {
    lazy[node] += x;
    push(node, start, end);
    return;
  }
  int mid = (start + end) >> 1;
  update(2 * node, start, mid, l, r, x);
  update(2 * node + 1, mid + 1, end, l, r, x);
  tree[node] = min(tree[2 * node], tree[2 * node + 1]);
  return;
}
long long int query(int node, int start, int end, int l, int r) {
  if (r < start || l > end) return inf;
  push(node, start, end);
  if (start >= l && end <= r) return tree[node];
  int mid = (start + end) >> 1;
  return min(query(2 * node, start, mid, l, r),
             query(2 * node + 1, mid + 1, end, l, r));
}
int finish[500010];
void dfs(int cur, int prev = -1, long long int w = 0LL) {
  long long int x = inf;
  if ((int)adj[cur].size() == 1 && cur != 1) {
    x = w;
  }
  update(1, 0, n - 1, cnt, cnt, x);
  id[cur] = cnt;
  cnt++;
  for (int i = 0; i < (int)adj[cur].size(); i++) {
    if (adj[cur][i].first == prev) continue;
    dfs(adj[cur][i].first, cur, w + adj[cur][i].second);
  }
  finish[cur] = cnt - 1;
}
long long int ans[500010];
void run(int cur, int prev = -1, long long int w = 0LL) {
  update(1, 0, n - 1, id[cur], finish[cur], -2 * w);
  update(1, 0, n - 1, 0, n - 1, w);
  for (auto &it : Q[cur]) {
    ans[it.first] = query(1, 0, n - 1, it.second.first, it.second.second);
  }
  for (int i = 0; i < (int)adj[cur].size(); i++) {
    if (adj[cur][i].first == prev) continue;
    run(adj[cur][i].first, cur, adj[cur][i].second);
  }
  update(1, 0, n - 1, id[cur], finish[cur], 2 * w);
  update(1, 0, n - 1, 0, n - 1, -w);
}
int main() {
  int q;
  scanf("%d %d", &n, &q);
  for (int i = 2; i <= n; i++) {
    int p;
    long long int w1;
    scanf("%d %lld", &p, &w1);
    adj[p].emplace_back(i, w1);
    adj[i].emplace_back(p, w1);
  }
  for (int i = 1; i <= n; i++) {
    sort(adj[i].begin(), adj[i].end());
  }
  dfs(1);
  for (int i = 0; i < q; i++) {
    int v, l, r;
    scanf("%d %d %d", &v, &l, &r);
    l--;
    r--;
    Q[v].push_back({i, {l, r}});
  }
  run(1);
  for (int i = 0; i < q; i++) {
    printf("%lld\n", ans[i]);
  }
  return 0;
}
