#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
long long POW(long long a, long long b, long long MMM = MOD) {
  long long ret = 1;
  for (; b; b >>= 1, a = (a * a) % MMM)
    if (b & 1) ret = (ret * a) % MMM;
  return ret;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) {
  if (a == 0 || b == 0) return a + b;
  return a * (b / gcd(a, b));
}
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, 1, -1};
vector<pair<int, int> > v[500001];
vector<tuple<int, int, int> > query[500001];
long long tree[1048576], lazy[1048576], ans[500000];
void propagation(int node, int S, int E) {
  if (lazy[node] != 0) {
    tree[node] += lazy[node];
    if (S != E) {
      lazy[2 * node] += lazy[node];
      lazy[2 * node + 1] += lazy[node];
    }
    lazy[node] = 0;
  }
}
void upd(int node, int S, int E, int i, int j, long long val) {
  propagation(node, S, E);
  if (i > E || j < S) return;
  if (j >= E && i <= S) {
    tree[node] += val;
    if (S != E) {
      lazy[node * 2] += val;
      lazy[node * 2 + 1] += val;
    }
    return;
  }
  upd(2 * node, S, (S + E) / 2, i, j, val);
  upd(2 * node + 1, (S + E) / 2 + 1, E, i, j, val);
  tree[node] = min(tree[2 * node], tree[2 * node + 1]);
}
long long find(int node, int S, int E, int i, int j) {
  propagation(node, S, E);
  if (i > E || j < S) return 987654321987654321;
  if (j >= E && i <= S) return tree[node];
  return min(find(node * 2, S, (S + E) / 2, i, j),
             find(2 * node + 1, (S + E) / 2 + 1, E, i, j));
}
int S[500005], E[500005];
int n, q;
void dfs1(int N, long long d) {
  S[N] = E[N] = N;
  if (v[N].empty())
    upd(1, 1, n, N, N, d);
  else
    upd(1, 1, n, N, N, 987654321987654321);
  for (auto P : v[N]) {
    dfs1(P.first, d + P.second);
    E[N] = max(E[N], E[P.first]);
  }
}
void dfs2(int N) {
  for (auto &I : query[N]) {
    int l, r, i;
    tie(l, r, i) = I;
    ans[i] = find(1, 1, n, l, r);
  }
  for (auto P : v[N]) {
    int L = S[P.first], R = E[P.first];
    upd(1, 1, n, 1, L - 1, P.second);
    upd(1, 1, n, L, R, -P.second);
    upd(1, 1, n, R + 1, n, P.second);
    dfs2(P.first);
    upd(1, 1, n, 1, L - 1, -P.second);
    upd(1, 1, n, L, R, P.second);
    upd(1, 1, n, R + 1, n, -P.second);
  }
}
int main() {
  scanf("%d%d", &n, &q);
  for (int(i) = (2); (i) <= (n); (i) += (1)) {
    int x, y;
    scanf("%d%d", &x, &y);
    v[x].push_back(make_pair(i, y));
  }
  for (int(i) = (0); (i) <= (q - 1); (i) += (1)) {
    int x, l, r;
    scanf("%d%d%d", &x, &l, &r);
    query[x].push_back(tuple<int, int, int>(l, r, i));
  }
  dfs1(1, 0);
  dfs2(1);
  for (int(i) = (0); (i) <= (q - 1); (i) += (1)) printf("%lld\n", ans[i]);
}
