#include <bits/stdc++.h>
using namespace std;
int q, n;
vector<pair<int, long long>> tree[500005];
bool deleted[500005];
int cd_father[500005];
int father[500005][30];
long long dist[500005];
int level[500005];
int subSize[500005];
struct TreeNode {
  vector<pair<int, long long>> leaves;
  vector<long long> tree;
  int n;
  void init() {
    n = leaves.size();
    sort(leaves.begin(), leaves.end());
    tree.resize(2 * n);
    for (int i = 0; i < n; i++) tree[n + i] = leaves[i].second;
    for (int i = n - 1; i > 0; i--) tree[i] = min(tree[2 * i], tree[2 * i + 1]);
  }
  long long query(int l, int r, bool convert = false) {
    if (leaves.size() == 0 || r < leaves.front().first ||
        leaves.back().first < l)
      return 1e16;
    if (convert) {
      l = lower_bound(leaves.begin(), leaves.end(),
                      make_pair(l, (long long)-1)) -
          leaves.begin();
      r = lower_bound(leaves.begin(), leaves.end(),
                      make_pair(r + 1, (long long)-1)) -
          leaves.begin();
    }
    long long ans = 1e16;
    for (l += n, r += n; l < r; l /= 2, r /= 2) {
      if (l & 1) ans = min(ans, tree[l++]);
      if (r & 1) ans = min(ans, tree[--r]);
    }
    return ans;
  }
} segTree[500005];
void dfs(int cur, int parent, long long d, int l) {
  dist[cur] = d;
  level[cur] = l;
  father[cur][0] = parent == -1 ? cur : parent;
  for (int i = 0; i < tree[cur].size(); i++)
    if (tree[cur][i].first != parent)
      dfs(tree[cur][i].first, cur, d + tree[cur][i].second, l + 1);
}
void lca_init() {
  for (int dep = 1; dep < 30; dep++)
    for (int i = 1; i <= n; i++)
      father[i][dep] = father[father[i][dep - 1]][dep - 1];
}
int get_lca(int x, int y) {
  if (level[x] < level[y]) swap(x, y);
  int d = level[x] - level[y];
  for (int i = 0; i < 30; i++)
    if (d & (1 << i)) x = father[x][i];
  if (x == y) return x;
  for (int i = 29; i >= 0; i--)
    if (father[x][i] != father[y][i]) x = father[x][i], y = father[y][i];
  return father[x][0];
}
long long get_dist(int x, int y) {
  return dist[x] + dist[y] - 2 * dist[get_lca(x, y)];
}
int dfs_sub_size(int cur, int parent) {
  subSize[cur] = 1;
  for (int i = 0; i < tree[cur].size(); i++) {
    int u = tree[cur][i].first;
    if (u != parent && !deleted[u]) subSize[cur] += dfs_sub_size(u, cur);
  }
  return subSize[cur];
}
int get_centroid(int cur, int parent, int n) {
  for (int i = 0; i < tree[cur].size(); i++)
    if (tree[cur][i].first != parent && !deleted[tree[cur][i].first] &&
        subSize[tree[cur][i].first] > n / 2)
      return get_centroid(tree[cur][i].first, cur, n);
  return cur;
}
void centroid_decomposition(int cur, int parent) {
  int n = dfs_sub_size(cur, parent);
  int centroid = get_centroid(cur, parent, n);
  cd_father[centroid] = parent;
  deleted[centroid] = true;
  for (int i = 0; i < tree[centroid].size(); i++) {
    int u = tree[centroid][i].first;
    if (u != parent && !deleted[u]) centroid_decomposition(u, centroid);
  }
}
void init() {
  dfs(1, -1, 0, 0);
  lca_init();
  centroid_decomposition(1, -1);
  for (int i = 2; i <= n; i++) {
    if (tree[i].size() != 1) continue;
    int cur = i;
    while (cur != -1) {
      segTree[cur].leaves.emplace_back(i, get_dist(i, cur));
      cur = cd_father[cur];
    }
  }
  for (int i = 1; i <= n; i++) {
    segTree[i].init();
  }
}
long long query(int v, int l, int r) {
  long long ans = 1e18;
  int p = v;
  while (p != -1) {
    ans = min(ans, segTree[p].query(l, r, true) + get_dist(v, p));
    p = cd_father[p];
  }
  return ans;
}
int main() {
  scanf("%d %d", &n, &q);
  for (int i = 2; i <= n; i++) {
    int p, w;
    scanf("%d %d", &p, &w);
    tree[i].emplace_back(p, w);
    tree[p].emplace_back(i, w);
  }
  init();
  int v, l, r;
  for (int i = 0; i < q; i++) {
    scanf("%d %d %d", &v, &l, &r);
    printf("%lld\n", query(v, l, r));
  }
  return 0;
}
