#include <bits/stdc++.h>
using namespace std;
inline int readChar();
template <class T = int>
inline T readInt();
template <class T>
inline void writeInt(T x, char end = 0);
inline void writeChar(int x);
inline void writeWord(const char *s);
static const int buf_size = 4096;
inline int getChar() {
  static char buf[buf_size];
  static int len = 0, pos = 0;
  if (pos == len) pos = 0, len = fread(buf, 1, buf_size, stdin);
  if (pos == len) return -1;
  return buf[pos++];
}
inline int readChar() {
  int c = getChar();
  while (c <= 32) c = getChar();
  return c;
}
template <class T>
inline T readInt() {
  int s = 1, c = readChar();
  T x = 0;
  if (c == '-') s = -1, c = getChar();
  while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getChar();
  return s == 1 ? x : -x;
}
static int write_pos = 0;
static char write_buf[buf_size];
inline void writeChar(int x) {
  if (write_pos == buf_size)
    fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
  write_buf[write_pos++] = x;
}
template <class T>
inline void writeInt(T x, char end) {
  if (x < 0) writeChar('-'), x = -x;
  char s[24];
  int n = 0;
  while (x || !n) s[n++] = '0' + x % 10, x /= 10;
  while (n--) writeChar(s[n]);
  if (end) writeChar(end);
}
inline void writeWord(const char *s) {
  while (*s) writeChar(*s++);
}
struct Flusher {
  ~Flusher() {
    if (write_pos) fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
  }
} flusher;
inline void readWord(char *s) {
  int c = readChar();
  while (c > 32) *s++ = c, c = getChar();
  *s = 0;
}
inline void writeDouble(double x, int output_len) {
  if (x < 0) writeChar('-'), x = -x;
  int t = (int)x;
  writeInt(t), x -= t;
  writeChar('.');
  for (int i = output_len - 1; i > 0; i--) {
    x *= 10;
    t = min(9, (int)x);
    writeChar('0' + t), x -= t;
  }
  x *= 10;
  t = min(9, (int)(x + 0.5));
  writeChar('0' + t);
}
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using ull = unsigned long long;
using pnt = complex<ll>;
istream &operator>>(istream &in, pnt &p) {
  ll a, b;
  in >> a >> b;
  p = {a, b};
  return in;
}
ll crs(pnt a, pnt b) { return a.real() * b.imag() - a.imag() * b.real(); }
ll dot(pnt a, pnt b) { return a.real() * b.real() + a.imag() * b.imag(); }
const int M = 998244353;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 1e18L;
const ld pi = acos(-1.0L);
const ld eps = 1e-8L;
const int di[] = {0, 1, -1, 0};
const int dj[] = {1, 0, 0, -1};
const int SQ = 1000;
const int LG = 19;
const int nax = 5e5 + 100;
struct node {
  ll mi, ad;
};
node t[4 * nax];
ll dep[nax];
void build(int v, int l, int r) {
  t[v].ad = 0;
  if (l == r) {
    t[v].mi = dep[l];
  } else {
    int m = (l + r) >> 1;
    build(v * 2 + 1, l, m);
    build(v * 2 + 2, m + 1, r);
    t[v].mi = min(t[v * 2 + 1].mi, t[v * 2 + 2].mi);
  }
}
void push(int v) {
  ll x = t[v].ad;
  if (x) {
    t[v].ad = 0;
    t[v * 2 + 1].mi += x;
    t[v * 2 + 1].ad += x;
    t[v * 2 + 2].mi += x;
    t[v * 2 + 2].ad += x;
  }
}
void upd(int v, int l, int r, int l1, int r1, ll x) {
  if (r < l1 || r1 < l) {
    return;
  }
  if (l1 <= l && r <= r1) {
    t[v].mi += x;
    t[v].ad += x;
    return;
  }
  push(v);
  int m = (l + r) >> 1;
  upd(v * 2 + 1, l, m, l1, r1, x);
  upd(v * 2 + 2, m + 1, r, l1, r1, x);
  t[v].mi = min(t[v * 2 + 1].mi, t[v * 2 + 2].mi);
}
ll get(int v, int l, int r, int l1, int r1) {
  if (r < l1 || r1 < l) {
    return inf64;
  }
  if (l1 <= l && r <= r1) {
    return t[v].mi;
  }
  push(v);
  int m = (l + r) >> 1;
  return min(get(v * 2 + 1, l, m, l1, r1), get(v * 2 + 2, m + 1, r, l1, r1));
}
struct query {
  int v, l, r;
};
int n, q;
vector<pii> g[nax];
ll ans[nax];
query qs[nax];
vi qi[nax];
int lb[nax], rb[nax];
void dfs(int v, int p) {
  lb[v] = v;
  rb[v] = v;
  for (pii e : g[v]) {
    if (e.first != p) {
      dep[e.first] = dep[v] + e.second;
      dfs(e.first, v);
      lb[v] = min(lb[v], lb[e.first]);
      rb[v] = max(rb[v], rb[e.first]);
    }
  }
}
void dfs1(int v, int p) {
  for (int id : qi[v]) {
    ans[id] = get(0, 0, n - 1, qs[id].l, qs[id].r);
  }
  for (pii e : g[v]) {
    int l = lb[e.first];
    int r = rb[e.first];
    if (l) {
      upd(0, 0, n - 1, 0, l - 1, e.second);
    }
    if (r != n - 1) {
      upd(0, 0, n - 1, r + 1, n - 1, e.second);
    }
    upd(0, 0, n - 1, l, r, -e.second);
    dfs1(e.first, v);
    upd(0, 0, n - 1, l, r, e.second);
    if (r != n - 1) {
      upd(0, 0, n - 1, r + 1, n - 1, -e.second);
    }
    if (l) {
      upd(0, 0, n - 1, 0, l - 1, -e.second);
    }
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout.precision(10);
  cout << fixed;
  n = readInt();
  q = readInt();
  for (int i = 1; i < n; i++) {
    int p = readInt() - 1;
    int w = readInt();
    g[p].push_back(make_pair(i, w));
  }
  for (int i = 0; i < q; i++) {
    int v = readInt() - 1;
    int l = readInt() - 1;
    int r = readInt() - 1;
    qs[i] = {v, l, r};
    qi[v].push_back(i);
  }
  dfs(0, -1);
  for (int i = 0; i < n; i++) {
    if (!g[i].empty()) {
      dep[i] = inf64;
    }
  }
  build(0, 0, n - 1);
  dfs1(0, -1);
  for (int i = 0; i < q; i++) {
    writeInt(ans[i], '\n');
  }
}
