#include <bits/stdc++.h>
using namespace std;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int mod = 1e9 + 7;
const long long inf = 1e12;
const int maxn = 5e5 + 10;
const double eps = 1e-6;
inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
inline long long sqr(long long x) { return x * x; }
inline long long fpow(long long a, long long b, long long c) {
  long long ret = 1 % c;
  for (; b; b >>= 1, a = a * a % c)
    if (b & 1) ret = ret * a % c;
  return ret;
}
inline long long read() {
  long long x = 0, f = 1;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = -1;
  } while (!isdigit(ch));
  do {
    x = x * 10 + ch - '0';
    ch = getchar();
  } while (isdigit(ch));
  return f * x;
}
vector<pair<int, long long> > G[maxn];
int n, m, size[maxn];
long long d[maxn], ans[maxn];
vector<int> q[maxn];
int l[maxn], r[maxn];
struct node {
  long long tag, mi;
} t[maxn << 2];
inline void pushup(int o) { t[o].mi = min(t[o << 1].mi, t[o << 1 | 1].mi); }
inline void pushdown(int o) {
  if (!t[o].tag) return;
  t[o << 1].tag += t[o].tag, t[o << 1].mi += t[o].tag;
  t[o << 1 | 1].tag += t[o].tag, t[o << 1 | 1].mi += t[o].tag;
  t[o].tag = 0;
}
void modify(int o, int l, int r, int x, int y, long long val) {
  if (l == x && r == y) {
    t[o].mi += val, t[o].tag += val;
    return;
  }
  int mid = l + r >> 1;
  pushdown(o);
  if (y <= mid)
    modify(o << 1, l, mid, x, y, val);
  else if (x > mid)
    modify(o << 1 | 1, mid + 1, r, x, y, val);
  else
    modify(o << 1, l, mid, x, mid, val),
        modify(o << 1 | 1, mid + 1, r, mid + 1, y, val);
  pushup(o);
}
long long query(int o, int l, int r, int x, int y) {
  if (l == x && r == y) return t[o].mi;
  int mid = l + r >> 1;
  pushdown(o);
  if (y <= mid)
    return query(o << 1, l, mid, x, y);
  else if (x > mid)
    return query(o << 1 | 1, mid + 1, r, x, y);
  else
    return min(query(o << 1, l, mid, x, mid),
               query(o << 1 | 1, mid + 1, r, mid + 1, y));
}
void dfs1(int u) {
  size[u] = 1;
  for (auto v : G[u]) {
    d[v.first] = d[u] + v.second;
    dfs1(v.first);
    size[u] += size[v.first];
  }
}
void read_and_parse() {
  n = read(), m = read();
  for (int i = 2; i <= n; i++) {
    int p = read(), w = read();
    G[p].push_back(make_pair(i, w));
  }
  dfs1(1);
  for (int i = 1; i <= n; i++)
    size[i] == 1 ? modify(1, 1, n, i, i, d[i]) : modify(1, 1, n, i, i, inf);
  for (int i = 1; i <= m; i++) {
    int v = read();
    l[i] = read(), r[i] = read();
    q[v].push_back(i);
  }
}
void dfs2(int u) {
  for (auto i : q[u]) ans[i] = query(1, 1, n, l[i], r[i]);
  for (auto v : G[u]) {
    modify(1, 1, n, 1, n, v.second);
    modify(1, 1, n, v.first, v.first + size[v.first] - 1, -v.second - v.second);
    dfs2(v.first);
    modify(1, 1, n, 1, n, -v.second);
    modify(1, 1, n, v.first, v.first + size[v.first] - 1, v.second + v.second);
  }
}
void solve() {
  dfs2(1);
  for (int i = 1; i <= m; i++) printf("%lld\n", ans[i]);
}
int main() {
  read_and_parse();
  solve();
  return 0;
}
