#include <bits/stdc++.h>
using namespace std;
int n, q, a, N = 1;
long long wa;
vector<pair<int, long long> > v[500007];
long long t[2000007];
long long lazy[2000007];
vector<int> w[500007];
int l[500007];
int r[500007];
int second[500007];
long long wy[500007];
long long M = 1e16 + 7;
void propagate(int x) {
  t[x * 2] += lazy[x];
  t[x * 2 + 1] += lazy[x];
  lazy[x * 2] += lazy[x];
  lazy[x * 2 + 1] += lazy[x];
  lazy[x] = 0;
}
void insert(int x, int a, int b, int L, int P, long long w) {
  if (a >= L && b <= P) {
    t[x] += w;
    lazy[x] += w;
    return;
  }
  int second = (a + b) / 2;
  propagate(x);
  if (second >= L) insert(x * 2, a, second, L, P, w);
  if (second + 1 <= P) insert(x * 2 + 1, second + 1, b, L, P, w);
  t[x] = min(t[x * 2], t[x * 2 + 1]);
}
long long query(int x, int a, int b, int L, int P) {
  if (a >= L && b <= P) return t[x];
  int second = (a + b) / 2;
  propagate(x);
  long long wy = 1e16 + 7;
  if (second >= L) wy = min(wy, query(x * 2, a, second, L, P));
  if (second + 1 <= P) wy = min(wy, query(x * 2 + 1, second + 1, b, L, P));
  t[x] = min(t[x * 2], t[x * 2 + 1]);
  return wy;
}
void dfs(int x) {
  for (int i = 0; i < v[x].size(); i++) {
    dfs(v[x][i].first);
    second[x] += second[v[x][i].first] + 1;
  }
  if (v[x].size() != 0) insert(1, 1, N, x, x, M);
}
void dfs2(int x) {
  for (int i = 0; i < v[x].size(); i++) {
    insert(1, 1, N, v[x][i].first, v[x][i].first + second[v[x][i].first],
           v[x][i].second);
    dfs2(v[x][i].first);
  }
}
void quest(int x) {
  for (int i = 0; i < v[x].size(); i++) {
    insert(1, 1, N, v[x][i].first, v[x][i].first + second[v[x][i].first],
           -2 * v[x][i].second);
    insert(1, 1, N, 1, N, v[x][i].second);
    quest(v[x][i].first);
    insert(1, 1, N, v[x][i].first, v[x][i].first + second[v[x][i].first],
           2 * v[x][i].second);
    insert(1, 1, N, 1, N, -v[x][i].second);
  }
  for (int i = 0; i < w[x].size(); i++) {
    wy[w[x][i]] = query(1, 1, N, l[w[x][i]], r[w[x][i]]);
  }
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; i++) {
    scanf("%d%lld", &a, &wa);
    v[a].push_back(make_pair(i, wa));
  }
  for (int i = 0; i < q; i++) {
    scanf("%d%d%d", &a, &l[i], &r[i]);
    w[a].push_back(i);
  }
  for (; N <= n; N *= 2)
    ;
  dfs(1);
  dfs2(1);
  quest(1);
  for (int i = 0; i < q; i++) printf("%lld\n", wy[i]);
}
