#include <bits/stdc++.h>
using namespace std;
int n, q, pre[500004], pst[500004], tm, dis[500004], sgt[500004], top;
long long ans[500004];
struct node {
  int l, r;
  long long d, tag;
  node *ls, *rs;
  void update() { d = min(ls->d, rs->d); }
  void pushd() {
    if (tag) {
      d += tag;
      if (ls) {
        ls->tag += tag;
      }
      if (rs) {
        rs->tag += tag;
      }
      tag = 0;
    }
  }
} * rt, pool[2 * 500004];
struct to {
  int y;
  long long w;
  to(int u, long long z) {
    w = z;
    y = u;
  }
  to() {}
};
struct quizs {
  int lp, rp, wj;
  quizs(int ax, int ay, int az) {
    lp = ax;
    rp = ay;
    wj = az;
  }
  quizs() {}
};
vector<to> t[500004];
vector<quizs> qz[500004];
void dfs1(int x) {
  pre[x] = tm;
  for (int i = 0; i < t[x].size(); i++) {
    if (dis[t[x][i].y] >= 0) {
      continue;
    }
    dis[t[x][i].y] = dis[x] + t[x][i].w;
    dfs1(t[x][i].y);
  }
  if (t[x].size() == 1) {
    sgt[tm] = x;
    tm++;
  }
  pst[x] = tm - 1;
  return;
}
node *buildt(int l, int r) {
  node *p = pool + (++top);
  p->l = l;
  p->r = r;
  if (l == r) {
    p->d = dis[sgt[l]];
    return p;
  }
  int mid = (l + r) / 2;
  p->ls = buildt(l, mid);
  p->rs = buildt(mid + 1, r);
  p->update();
}
void change(node *&p, int l, int r, long long x) {
  if (l > r) {
    return;
  }
  if (p->l == l && p->r == r) {
    p->tag += x;
    return;
  }
  int mid = (p->l + p->r) / 2;
  if (r <= mid) {
    change(p->ls, l, r, x);
  } else if (l > mid) {
    change(p->rs, l, r, x);
  } else {
    change(p->ls, l, mid, x);
    change(p->rs, mid + 1, r, x);
  }
  return;
}
long long query(node *&p, int l, int r) {
  p->pushd();
  if (p->l == l && p->r == r) {
    return p->d;
  }
  int mid = (p->l + p->r) / 2;
  if (r <= mid) {
    return query(p->ls, l, r);
  } else if (l > mid) {
    return query(p->rs, l, r);
  } else {
    return min(query(p->ls, l, mid), query(p->rs, mid + 1, r));
  }
}
void dfstt(node *p) {
  if (!p->ls && !p->rs) {
    cout << p->l << " " << p->d << endl;
    return;
  }
  dfstt(p->ls);
  dfstt(p->rs);
}
void dfs2(int x) {
  for (int i = 0; i < qz[x].size(); i++) {
    ans[qz[x][i].wj] = query(rt, qz[x][i].lp, qz[x][i].rp);
  }
  for (int i = 0; i < t[x].size(); i++) {
    if (dis[t[x][i].y] < dis[x]) {
      continue;
    }
    change(rt, 1, pre[t[x][i].y] - 1, t[x][i].w);
    change(rt, pst[t[x][i].y] + 1, tm, t[x][i].w);
    change(rt, pre[t[x][i].y], pst[t[x][i].y], -t[x][i].w);
    dfs2(t[x][i].y);
    change(rt, 1, pre[t[x][i].y] - 1, -t[x][i].w);
    change(rt, pst[t[x][i].y] + 1, tm, -t[x][i].w);
    change(rt, pre[t[x][i].y], pst[t[x][i].y], t[x][i].w);
  }
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; i++) {
    dis[i] = -1;
    int x;
    long long w;
    scanf("%d%lld", &x, &w);
    t[x].push_back(to(i, w));
    t[i].push_back(to(x, w));
  }
  tm = 1;
  dfs1(1);
  tm--;
  rt = buildt(1, tm);
  for (int i = 1; i <= q; i++) {
    int x, l, r;
    scanf("%d%d%d", &x, &l, &r);
    qz[x].push_back(quizs(pre[l], pre[r], i));
  }
  dfs2(1);
  for (int i = 1; i <= q; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}
