#include <bits/stdc++.h>
using namespace std;
const int maxn = 500005;
const long long inf = 0x3f3f3f3f3f3f3f3f;
int n, m, st[maxn], ed[maxn], tim;
long long a[maxn], dis[maxn], ans[maxn], mn[maxn << 2], add[maxn << 2];
vector<pair<int, int> > G[maxn];
struct Query {
  int l, r, id;
};
vector<Query> q[maxn];
void dfs(int x) {
  sort(G[x].begin(), G[x].end());
  st[x] = ++tim, a[tim] = G[x].empty() ? dis[x] : inf;
  for (auto y : G[x]) {
    dis[y.first] = dis[x] + y.second;
    dfs(y.first);
  }
  ed[x] = tim;
}
void build(int rt, int l, int r) {
  if (l == r) {
    mn[rt] = a[l];
    return;
  }
  int mid = (l + r) >> 1;
  build((rt << 1), l, mid), build((rt << 1 | 1), mid + 1, r),
      mn[rt] = min(mn[(rt << 1)], mn[(rt << 1 | 1)]);
}
inline void pushdown(int rt) {
  if (add[rt])
    mn[(rt << 1)] += add[rt], mn[(rt << 1 | 1)] += add[rt],
        add[(rt << 1)] += add[rt], add[(rt << 1 | 1)] += add[rt], add[rt] = 0;
}
void update(int rt, int l, int r, int x, int y, int z) {
  if (x <= l && r <= y) {
    mn[rt] += z, add[rt] += z;
    return;
  }
  pushdown(rt);
  int mid = (l + r) >> 1;
  if (x <= mid) update((rt << 1), l, mid, x, y, z);
  if (y > mid) update((rt << 1 | 1), mid + 1, r, x, y, z);
  mn[rt] = min(mn[(rt << 1)], mn[(rt << 1 | 1)]);
}
long long query(int rt, int l, int r, int x, int y) {
  if (x <= l && r <= y) return mn[rt];
  pushdown(rt);
  int mid = (l + r) >> 1;
  long long ans = inf;
  if (x <= mid) ans = min(ans, query((rt << 1), l, mid, x, y));
  if (y > mid) ans = min(ans, query((rt << 1 | 1), mid + 1, r, x, y));
  return ans;
}
void solve(int x) {
  for (auto y : q[x]) ans[y.id] = query(1, 1, n, y.l, y.r);
  for (auto y : G[x]) {
    update(1, 1, n, 1, n, y.second);
    update(1, 1, n, st[y.first], ed[y.first], -2 * y.second);
    solve(y.first);
    update(1, 1, n, 1, n, -y.second);
    update(1, 1, n, st[y.first], ed[y.first], 2 * y.second);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  int fa, w, x, l, r;
  for (int i = 2; i <= n; i++)
    scanf("%d%d", &fa, &w), G[fa].push_back(pair<int, int>(i, w));
  dfs(1), build(1, 1, n);
  for (int i = 1; i <= m; i++)
    scanf("%d%d%d", &x, &l, &r), q[x].push_back((Query){l, r, i});
  solve(1);
  for (int i = 1; i <= m; i++) printf("%lld\n", ans[i]);
  return 0;
}
