#include <bits/stdc++.h>
using namespace std;
int n, q, head[500500], cnt, sd[500500], flag[500500 << 2], num;
long long mi[500500 << 2], val[500500 << 2], depth[500500 << 2],
    tag[500500 << 2], size[500500];
vector<pair<int, long long> > side[500500];
struct node {
  int v, l, r;
  long long ans;
  int id;
} qu[500500];
bool com(node x, node y) { return x.v < y.v; }
void dfs1(int now, int fa) {
  size[now] = 1;
  if ((now == 1 && sd[now] == 0) || (now != 1 && sd[now] == 1)) {
    flag[now] = 1;
    return;
  }
  for (int i = 0; i < side[now].size(); i++) {
    int v = side[now][i].first;
    if (v == fa) continue;
    depth[v] = depth[now] + side[now][i].second;
    dfs1(v, now);
    size[now] += size[v];
  }
}
void push_down(int x) {
  tag[x << 1] += tag[x];
  tag[x << 1 | 1] += tag[x];
  mi[x << 1] += tag[x];
  mi[x << 1 | 1] += tag[x];
  tag[x] = 0;
}
void push_up(int x) { mi[x] = min(mi[x << 1], mi[x << 1 | 1]); }
void change(int l, int r, int root, int tl, int tr, long long val) {
  if (tl <= l && r <= tr) {
    tag[root] += val;
    mi[root] += val;
    return;
  }
  push_down(root);
  int mid = (l + r) >> 1;
  if (tl <= mid) change(l, mid, root << 1, tl, tr, val);
  if (tr >= mid + 1) change(mid + 1, r, root << 1 | 1, tl, tr, val);
  push_up(root);
  return;
}
long long query(int l, int r, int root, int tl, int tr) {
  if (tl <= l && r <= tr) {
    return mi[root];
  }
  push_down(root);
  long long tmp = 1e18 + 1000;
  int mid = (l + r) >> 1;
  if (tl <= mid) tmp = min(tmp, query(l, mid, root << 1, tl, tr));
  if (tr >= mid + 1) tmp = min(tmp, query(mid + 1, r, root << 1 | 1, tl, tr));
  return tmp;
}
bool cop(node x, node y) { return x.v < y.v; }
bool cop2(node x, node y) { return x.id < y.id; }
void dfs2(int now, int fa) {
  while (num < q && qu[num + 1].v == now) {
    num++;
    qu[num].ans = query(1, n, 1, qu[num].l, qu[num].r);
    if (qu[num].ans == 0) {
      int gggg = 0;
    }
  }
  for (int i = 0; i < side[now].size(); i++) {
    int v = side[now][i].first;
    if (v == fa) continue;
    long long w = side[now][i].second;
    change(1, n, 1, v, v + size[v] - 1, -w);
    change(1, n, 1, 1, v - 1, w);
    change(1, n, 1, v + size[v], n, w);
    dfs2(v, now);
    change(1, n, 1, v, v + size[v] - 1, w);
    change(1, n, 1, 1, v - 1, -w);
    change(1, n, 1, v + size[v], n, -w);
  }
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; i++) {
    int u, v, w;
    scanf("%d%d", &u, &w);
    side[u].push_back(make_pair(i, w));
    side[i].push_back(make_pair(u, w));
    sd[u]++;
    sd[i]++;
  }
  for (int i = 1; i <= q; i++) {
    scanf("%d%d%d", &qu[i].v, &qu[i].l, &qu[i].r);
    qu[i].id = i;
  }
  sort(qu + 1, qu + 1 + q, cop);
  dfs1(1, 0);
  for (int i = 1; i <= n; i++) {
    if (flag[i]) {
      change(1, n, 1, i, i, depth[i]);
    } else {
      change(1, n, 1, i, i, 1e18 + 1000);
    }
  }
  dfs2(1, 0);
  sort(qu + 1, qu + 1 + q, cop2);
  for (int i = 1; i <= q; i++) {
    printf("%lld\n", qu[i].ans);
  }
  return 0;
}
