#include <bits/stdc++.h>
using namespace std;
long long data1[(1 << 20) + 10], data2[(1 << 20) + 10];
struct segment_tree {
  inline void update(long long v, long long l, long long r, long long lx,
                     long long rx, long long x) {
    if (lx >= r || l >= rx) return;
    if (lx <= l && r <= rx) {
      data1[v] += x;
      data2[v] += x;
      return;
    }
    long long mid = (l + r) >> 1;
    update(v << 1, l, mid, lx, rx, x);
    update((v << 1) + 1, mid, r, lx, rx, x);
    data1[v] = min(data1[v << 1], data1[(v << 1) + 1]) + data2[v];
  }
  inline long long query(long long v, long long l, long long r, long long lx,
                         long long rx) {
    if (lx >= r || l >= rx) return 1000000000000000007;
    if (lx <= l && r <= rx) return data1[v];
    long long mid = (l + r) >> 1;
    return min(query(v << 1, l, mid, lx, rx),
               query((v << 1) + 1, mid, r, lx, rx)) +
           data2[v];
  }
} seg;
long long n, que, ans[500010], dist[500010], deg[500010], fa[500010],
    sz[500010];
vector<pair<long long, long long> > v[500010];
vector<pair<pair<long long, long long>, long long> > q[500010];
inline void dist_dfs(long long u, long long d, long long pr) {
  sz[u] = 1;
  for (long long i = 0; i < v[u].size(); i++)
    if (v[u][i].first != pr) {
      dist[v[u][i].first] = d + v[u][i].second;
      fa[v[u][i].first] = u;
      dist_dfs(v[u][i].first, d + v[u][i].second, u);
      sz[u] += sz[v[u][i].first];
    }
}
inline void ans_dfs(long long u, long long pr) {
  for (long long i = 0; i < q[u].size(); i++) {
    if (deg[u] == 1 && u >= q[u][i].first.first && u <= q[u][i].first.second)
      ans[q[u][i].second] = 0;
    else
      ans[q[u][i].second] =
          seg.query(1, 1, n + 1, q[u][i].first.first, q[u][i].first.second + 1);
  }
  for (long long i = 0; i < v[u].size(); i++)
    if (v[u][i].first != pr) {
      seg.update(1, 1, n + 1, v[u][i].first, v[u][i].first + sz[v[u][i].first],
                 -v[u][i].second - v[u][i].second);
      seg.update(1, 1, n + 1, 1, n + 1, v[u][i].second);
      ans_dfs(v[u][i].first, u);
      seg.update(1, 1, n + 1, v[u][i].first, v[u][i].first + sz[v[u][i].first],
                 v[u][i].second + v[u][i].second);
      seg.update(1, 1, n + 1, 1, n + 1, -v[u][i].second);
    }
}
signed main() {
  ios::sync_with_stdio(false);
  cin >> n >> que;
  for (long long i = 2; i <= n; i++) {
    long long x, w;
    cin >> x >> w;
    v[i].push_back(make_pair(x, w));
    v[x].push_back(make_pair(i, w));
    deg[i]++;
    deg[x]++;
  }
  for (long long i = 1; i <= que; i++) {
    long long val, l, r;
    cin >> val >> l >> r;
    q[val].push_back(make_pair(make_pair(l, r), i));
  }
  dist[1] = 0;
  fa[1] = 1;
  dist_dfs(1, 0, -1);
  for (long long i = 1; i <= n; i++) {
    if (deg[i] == 1) {
      seg.update(1, 1, n + 1, i, i + 1, dist[i]);
    } else
      seg.update(1, 1, n + 1, i, i + 1, 1000000000000000007);
  }
  ans_dfs(1, -1);
  for (long long i = 1; i <= que; i++) cout << ans[i] << endl;
  return 0;
}
