#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
struct Node {
  int priority;
  int v;
  long long d;
  long long min_d;
  Node *left;
  Node *right;
  Node(int _v, int _d) {
    v = _v;
    min_d = d = _d;
    priority = rand() * RAND_MAX + rand();
    left = nullptr;
    right = nullptr;
  }
};
long long min_d(Node *t) {
  if (t == nullptr) return INF;
  return t->min_d;
}
void recalc(Node *t) {
  t->min_d = min(t->d, min(min_d(t->left), min_d(t->right)));
}
pair<Node *, Node *> split(Node *t, int v) {
  if (t == nullptr) return make_pair(nullptr, nullptr);
  if (t->v < v) {
    auto tmp = split(t->right, v);
    t->right = tmp.first;
    recalc(t);
    return make_pair(t, tmp.second);
  }
  auto tmp = split(t->left, v);
  t->left = tmp.second;
  recalc(t);
  return make_pair(tmp.first, t);
}
Node *merge(Node *a, Node *b) {
  if (a == nullptr) return b;
  if (b == nullptr) return a;
  if (a->priority < b->priority) {
    a->right = merge(a->right, b);
    recalc(a);
    return a;
  }
  b->left = merge(a, b->left);
  recalc(b);
  return b;
}
Node *add(Node *t, int v, long long d) {
  Node *node = new Node(v, d);
  auto tmp = split(t, v);
  return merge(merge(tmp.first, node), tmp.second);
}
pair<long long, Node *> get(Node *t, int l, int r) {
  auto tmp1 = split(t, l);
  auto tmp2 = split(tmp1.second, r);
  long long ans = min_d(tmp2.first);
  return make_pair(ans, merge(tmp1.first, merge(tmp2.first, tmp2.second)));
}
vector<pair<int, int>> G[500000];
int level[500000];
int sz[500000];
int par[500000];
long long dist[20][500000];
Node *trees[500000];
void dfs1(int v, int p) {
  sz[v] = 1;
  for (auto t : G[v]) {
    int u = t.first;
    if (level[u] > 0 || u == p) continue;
    dfs1(u, v);
    sz[v] += sz[u];
  }
}
void dfs2(int v, int p, int c, long long d) {
  if (G[v].size() == 1) trees[c] = add(trees[c], v, d);
  dist[level[c]][v] = d;
  for (auto t : G[v]) {
    int u = t.first;
    if (level[u] > 0 || u == p) continue;
    dfs2(u, v, c, d + t.second);
  }
}
int calc(int v, int d) {
  dfs1(v, -1);
  int u = v, p = -1;
  while (true) {
    int best = -1;
    for (auto t : G[u]) {
      int _u = t.first;
      if (level[_u] > 0 || _u == p) continue;
      if (best == -1 || sz[_u] > sz[best]) best = _u;
    }
    if (best == -1 || sz[best] * 2 < sz[v]) break;
    p = u;
    u = best;
  }
  level[u] = d;
  dfs2(u, -1, u, 0);
  for (auto t : G[u]) {
    int _u = t.first;
    if (level[_u] > 0) continue;
    par[calc(_u, d + 1)] = u;
  }
  return u;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, q;
  cin >> n >> q;
  for (int i = 1; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    G[i].emplace_back(a, b);
    G[a].emplace_back(i, b);
  }
  for (int i = 0; i < n; ++i) trees[i] = nullptr;
  par[calc(0, 1)] = -1;
  while (q--) {
    int v, l, r;
    cin >> v >> l >> r;
    --v;
    long long ans = INF;
    for (int u = v; u != -1; u = par[u]) {
      auto tmp = get(trees[u], l - 1, r);
      trees[u] = tmp.second;
      ans = min(ans, tmp.first + dist[level[u]][v]);
    }
    cout << ans << '\n';
  }
  return 0;
}
