#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5, M = 22;
const long long INF = 1e18;
int n, m;
int p[N], d[N];
bool used[N];
int step[N];
long long dp[M][N];
long long dist[M][N], ans[N];
vector<pair<int, long long> > q[N];
vector<pair<int, int> > g[N];
vector<pair<pair<int, int>, pair<int, int> > > f[N];
int dfs(int v, int size, int &center, int pr = -1) {
  int sz = 1;
  for (auto it : g[v]) {
    int to = it.first;
    if (to != pr && !used[to]) {
      sz += dfs(to, size, center, v);
    }
  }
  if (center == -1 && sz >= size / 2) {
    center = v;
  }
  return sz;
}
void dfs1(int v, int depth, int pr = -1, long long len = 0) {
  dist[depth][v] = len;
  for (auto it : g[v]) {
    int to = it.first, val = it.second;
    if (to != pr && !used[to]) {
      dfs1(to, depth, v, len + val);
    }
  }
}
void build(int v, int pr = -1, int depth = 0) {
  int center = -1, tmp = 0;
  dfs(v, dfs(v, 0, tmp), center);
  dfs1(center, depth);
  used[center] = true;
  d[center] = depth;
  p[center] = pr;
  for (auto it : g[center]) {
    int to = it.first;
    if (!used[to]) {
      build(to, center, depth + 1);
    }
  }
}
inline long long get_min(int l, int r) {
  int x = step[r - l + 1];
  return min(dp[x][l], dp[x][r - (1 << x) + 1]);
}
int main() {
  srand(time(nullptr));
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  for (int i = 2; i < N; i++) {
    step[i] = step[i >> 1] + 1;
  }
  cin >> n >> m;
  for (int i = 2; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(make_pair(i, y));
    g[i].push_back(make_pair(x, y));
  }
  build(1);
  for (int i = 2; i <= n; i++) {
    if ((int)g[i].size() == 1) {
      int cur = i;
      while (cur != -1) {
        q[cur].push_back(make_pair(i, dist[d[cur]][i]));
        cur = p[cur];
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    sort(q[i].begin(), q[i].end());
  }
  for (int i = 1; i <= m; i++) {
    int v, l, r;
    cin >> v >> l >> r;
    ans[i] = INF;
    int cur = v;
    while (cur != -1) {
      int tl = lower_bound(q[cur].begin(), q[cur].end(), make_pair(l, -1LL)) -
               q[cur].begin(),
          tr = lower_bound(q[cur].begin(), q[cur].end(),
                           make_pair(r + 1, -1LL)) -
               q[cur].begin() - 1;
      if (tl <= tr) {
        f[cur].push_back(make_pair(make_pair(i, dist[d[cur]][v]),
                                   make_pair(tl + 1, tr + 1)));
      }
      cur = p[cur];
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!q[i].empty()) {
      int sz = (int)q[i].size();
      for (int j = 1; j <= sz; j++) {
        dp[0][j] = q[i][j - 1].second;
      }
      for (int j = 1; j <= step[sz]; j++) {
        for (int k = 1; k + (1 << j) - 1 <= sz; k++) {
          dp[j][k] = min(dp[j - 1][k], dp[j - 1][k + (1 << (j - 1))]);
        }
      }
      for (auto it : f[i]) {
        int ind = it.first.first;
        ans[ind] = min(ans[ind], it.first.second + get_min(it.second.first,
                                                           it.second.second));
      }
    }
  }
  for (int i = 1; i <= m; i++) {
    cout << ans[i] << "\n";
  }
}
