#include <bits/stdc++.h>
using namespace std;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                         {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};
const long long INF = 1000000000000000000;
struct SEG {
  int siz = 1 << 19;
  long long s[1 << 20];
  long long t[1 << 20];
  void init() {
    for (int i = 0; i < 2 * siz - 1; i++) {
      s[i] = 0;
      t[i] = 0;
    }
  }
  void add(int a, int b, long long x, int k, int l, int r) {
    if (b <= l || r <= a) return;
    if (a <= l && r <= b) {
      s[k] += x;
      t[k] += x;
      return;
    }
    add(a, b, x, 2 * k + 1, l, (l + r) / 2);
    add(a, b, x, 2 * k + 2, (l + r) / 2, r);
    s[k] = min(s[2 * k + 1], s[2 * k + 2]) + t[k];
  }
  long long query(int a, int b, int k, int l, int r) {
    if (b <= l || r <= a) return INF;
    if (a <= l && r <= b) return s[k];
    long long chl = query(a, b, 2 * k + 1, l, (l + r) / 2);
    long long chr = query(a, b, 2 * k + 2, (l + r) / 2, r);
    return min(chl, chr) + t[k];
  }
} seg;
int main() {
  static int n, q;
  static int p[500010];
  static long long w[500010];
  static int v[500010], l[500010], r[500010];
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; i++) {
    scanf("%d%lld", &p[i], &w[i]);
  }
  for (int i = 0; i < q; i++) scanf("%d%d%d", &v[i], &l[i], &r[i]);
  static int R[500010];
  for (int i = 1; i <= n; i++) R[i] = i;
  for (int i = n; i >= 2; --i) {
    R[p[i]] = max(R[p[i]], R[i]);
  }
  seg.init();
  static int cnt[500010] = {};
  for (int i = 1; i <= n; i++) {
    cnt[p[i]]++;
  }
  static long long d[500010];
  d[1] = 0;
  seg.add(1, 2, INF, 0, 0, seg.siz);
  for (int i = 2; i <= n; i++) {
    d[i] = d[p[i]] + w[i];
    seg.add(i, i + 1, cnt[i] == 0 ? d[i] : INF, 0, 0, seg.siz);
  }
  static vector<pair<pair<int, int>, pair<int, int> > > Que;
  for (int i = 0; i < q; i++)
    Que.push_back(pair<pair<int, int>, pair<int, int> >(
        pair<int, int>(v[i], i), pair<int, int>(l[i], r[i])));
  sort(Que.begin(), Que.end());
  static long long ans[500010];
  int k = 0;
  for (int i = 1; i <= n; i++) {
    while (k < Que.size() && Que[k].first.first == i) {
      ans[Que[k].first.second] = seg.query(
          Que[k].second.first, Que[k].second.second + 1, 0, 0, seg.siz);
      k++;
    }
    if (i == n) break;
    int loc = i;
    while (loc != p[i + 1]) {
      seg.add(0, seg.siz, -w[loc], 0, 0, seg.siz);
      seg.add(loc, R[loc] + 1, 2 * w[loc], 0, 0, seg.siz);
      loc = p[loc];
    }
    seg.add(0, seg.siz, w[i + 1], 0, 0, seg.siz);
    seg.add(i + 1, R[i + 1] + 1, -2 * w[i + 1], 0, 0, seg.siz);
  }
  for (int i = 0; i < q; i++) {
    printf("%lld\n", ans[i]);
  }
}
