#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f3f3f3f3f;
vector<pair<int, int> > from[500010];
vector<pair<pair<int, int>, int> > q[500010];
long long dist[500010], ans[500010];
int size[500010], in[500010];
vector<int> node;
struct ST_table {
  long long f[500010][20];
  int n;
  void init(vector<int> a) {
    n = a.size();
    for (int i = 0; i < n; i++) {
      f[i][0] = dist[a[i]];
    }
    for (int j = 1; j < 20; j++) {
      for (int i = 0; i < n; i++) {
        if (i + (1 << j) - 1 >= n) break;
        f[i][j] = min(f[i][j - 1], f[i + (1 << j - 1)][j - 1]);
      }
    }
  }
  long long minj(int l, int r) {
    int k = log(r - l + 1) / log(2);
    return min(f[l][k], f[r - (1 << k) + 1][k]);
  }
} st;
void dfs(int x, int last, int p) {
  if (p) node.push_back(x);
  size[x] = 1;
  for (int i = 0; i < from[x].size(); i++) {
    int v = from[x][i].first, w = from[x][i].second;
    if (v == last) continue;
    dist[v] = dist[x] + w, dfs(v, x, p);
    size[x] += size[v];
  }
}
int find_middle(int x) {
  dist[x] = 0, dfs(x, x, 0);
  int tot = size[x];
  while (1) {
    int nxt = x;
    for (int i = 0; i < from[x].size(); i++) {
      int v = from[x][i].first;
      if (size[v] < size[x] && 2 * size[v] >= tot) {
        nxt = v;
        break;
      }
    }
    if (nxt == x) break;
    x = nxt;
  }
  return x;
}
void query(int x) {
  node.clear(), dist[x] = 0, dfs(x, x, 1);
  vector<int> leaf;
  for (int i = 0; i < node.size(); i++) {
    if (in[node[i]] == 1) leaf.push_back(node[i]);
  }
  sort(leaf.begin(), leaf.end());
  st.init(leaf);
  for (int i = 0; i < node.size(); i++) {
    int v = node[i];
    for (int j = 0; j < q[v].size(); j++) {
      int l = q[v][j].first.first, r = q[v][j].first.second,
          id = q[v][j].second;
      l = lower_bound(leaf.begin(), leaf.end(), l) - leaf.begin();
      r = lower_bound(leaf.begin(), leaf.end(), r + 1) - leaf.begin();
      if (l <= r - 1) ans[id] = min(ans[id], st.minj(l, r - 1) + dist[v]);
    }
  }
}
void Erase(int u, int v) {
  for (int i = 0; i < from[u].size(); i++) {
    if (from[u][i].first == v) {
      swap(from[u].back(), from[u][i]);
      from[u].pop_back();
      return;
    }
  }
}
void solve(int x) {
  x = find_middle(x);
  query(x);
  for (int i = 0; i < from[x].size(); i++) {
    int v = from[x][i].first;
    Erase(v, x);
    solve(v);
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 2; i <= n; i++) {
    int x, w;
    scanf("%d%d", &x, &w);
    from[i].push_back(make_pair(x, w));
    from[x].push_back(make_pair(i, w));
    in[i]++, in[x]++;
  }
  for (int i = 0; i < m; i++) {
    int x, l, r;
    scanf("%d%d%d", &x, &l, &r);
    q[x].push_back(make_pair(make_pair(l, r), i));
    ans[i] = INF;
  }
  solve(1);
  for (int i = 0; i < m; i++) {
    printf("%I64d\n", ans[i]);
  }
  return 0;
}
