#include <bits/stdc++.h>
#pragma GCC optimize("O3")
const double PI = acos(-1.0);
using namespace std;
const int N = 500007, M = 1000000;
const double EPS = 1e-9, eps = -1e9;
int n, q, num[N], c, mxleaf[N];
long long dis[N], val[N * 20], laz[N * 20], a[N], ans[N];
vector<pair<int, int>> adj[N];
vector<pair<int, pair<int, int>>> qlist[N];
void dfs(int u) {
  num[u] = ++c;
  for (auto v : adj[u]) {
    dis[v.first] = dis[u] + (long long)v.second;
    dfs(v.first);
    mxleaf[u] = max(mxleaf[u], mxleaf[v.first]);
  }
  if ((int)adj[u].size() == 0)
    a[num[u]] = dis[u];
  else
    a[num[u]] = 4e18;
  mxleaf[u] = max(mxleaf[u], num[u]);
}
long long bulid(int s = 1, int e = n, int p = 1) {
  if (s == e) return val[p] = a[s];
  int mid = (s + e) / 2;
  return val[p] = min(bulid(s, mid, p * 2), bulid(mid + 1, e, p * 2 + 1));
}
void lazy(int p) {
  val[p * 2] += laz[p];
  laz[p * 2] += laz[p];
  val[p * 2 + 1] += laz[p];
  laz[p * 2 + 1] += laz[p];
  laz[p] = 0;
}
long long up(int s, int e, int p, int l, int r, int v) {
  if (s > e || l > r) return 0;
  if (s >= l && e <= r) {
    laz[p] += v;
    val[p] += v;
    return val[p];
  }
  lazy(p);
  int mid = (s + e) / 2;
  if (r <= mid)
    return val[p] = min(up(s, mid, p * 2, l, r, v), val[p * 2 + 1]);
  else if (l > mid)
    return val[p] = min(val[p * 2], up(mid + 1, e, p * 2 + 1, l, r, v));
  else
    return val[p] = min(up(s, mid, p * 2, l, r, v),
                        up(mid + 1, e, p * 2 + 1, l, r, v));
}
long long query(int s, int e, int p, int l, int r) {
  if (s > e || l > r) return 0;
  if (s >= l && e <= r) return val[p];
  lazy(p);
  int mid = (s + e) / 2;
  if (r <= mid)
    return query(s, mid, p * 2, l, r);
  else if (l > mid)
    return query(mid + 1, e, p * 2 + 1, l, r);
  else
    return min(query(s, mid, p * 2, l, r), query(mid + 1, e, p * 2 + 1, l, r));
}
void get(int u) {
  for (auto p : qlist[u])
    ans[p.first] = query(1, n, 1, p.second.first, p.second.second);
  for (auto v : adj[u]) {
    up(1, n, 1, num[v.first], mxleaf[v.first], -v.second);
    up(1, n, 1, 1, num[v.first] - 1, v.second);
    up(1, n, 1, mxleaf[v.first] + 1, n, v.second);
    get(v.first);
    up(1, n, 1, num[v.first], mxleaf[v.first], v.second);
    up(1, n, 1, 1, num[v.first] - 1, -v.second);
    up(1, n, 1, mxleaf[v.first] + 1, n, -v.second);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  cin >> n >> q;
  int p, w;
  for (int i = 2; i <= n; i++) {
    cin >> p >> w;
    adj[p].push_back({i, w});
  }
  dfs(1);
  bulid();
  int v, l, r;
  for (int i = 1; i <= q; i++) {
    cin >> v >> l >> r;
    qlist[v].push_back({i, {l, r}});
  }
  get(1);
  for (int i = 1; i <= q; i++) cout << ans[i] << endl;
  return 0;
}
