#include <bits/stdc++.h>
using namespace std;
vector<int> adj[500010];
vector<long long int> cost[500010];
const int LN = 17;
int lca[LN][500010], depth[500010];
long long int w[500010];
const long long int inf = 1e18;
namespace LCA {
void dfs(int cur, int prev = -1, int _depth = 0) {
  if (cur == 1) w[cur] = 0;
  lca[0][cur] = prev;
  depth[cur] = _depth;
  for (int i = 0; i < adj[cur].size(); i++)
    if (adj[cur][i] != prev) {
      w[adj[cur][i]] = w[cur] + 1LL * cost[cur][i];
      dfs(adj[cur][i], cur, _depth + 1);
    }
}
int LCA(int u, int v) {
  if (depth[u] < depth[v]) swap(u, v);
  int diff = depth[u] - depth[v];
  for (int i = 0; i < LN; i++)
    if ((diff >> i) & 1) u = lca[i][u];
  if (u == v) return u;
  for (int i = LN - 1; i >= 0; i--)
    if (lca[i][u] != lca[i][v]) {
      u = lca[i][u];
      v = lca[i][v];
    }
  return lca[0][u];
}
void LCA(int n) {
  memset(lca, -1, sizeof(lca));
  LCA::dfs(1);
  for (int i = 1; i < LN; i++)
    for (int j = 1; j <= n; j++)
      if (lca[i - 1][j] != -1) lca[i][j] = lca[i - 1][lca[i - 1][j]];
}
long long int dist(int u, int v) {
  int x = LCA(u, v);
  return w[u] + w[v] - 2 * w[x];
}
}  // namespace LCA
int decomposed[500010], subtree[500010], sz = 0;
bool visited[500010] = {false};
namespace CD {
void dfs(int cur, int prev) {
  subtree[cur] = 1;
  sz++;
  for (auto u : adj[cur]) {
    if (u != prev && !visited[u]) {
      dfs(u, cur);
      subtree[cur] += subtree[u];
    }
  }
}
int centroid(int cur, int prev) {
  for (auto u : adj[cur]) {
    if (u != prev && !visited[u] && subtree[u] > sz / 2)
      return centroid(u, cur);
  }
  return cur;
}
void decomposition(int root, int prev) {
  sz = 0;
  dfs(root, -1);
  int C = centroid(root, -1);
  if (prev == -1)
    decomposed[C] = C;
  else
    decomposed[C] = prev;
  visited[C] = true;
  for (auto u : adj[C])
    if (!visited[u]) decomposition(u, C);
}
}  // namespace CD
struct ST {
  vector<pair<int, long long int> > nodes;
  int n;
  long long int *tree;
  void add(int id, long long int c) { nodes.emplace_back(id, c); }
  void build(int node, int start, int end) {
    if (start == end) {
      tree[node] = nodes[start].second;
      return;
    }
    int mid = (start + end) >> 1;
    build(2 * node, start, mid);
    build(2 * node + 1, mid + 1, end);
    tree[node] = min(tree[2 * node], tree[2 * node + 1]);
  }
  void ini() {
    n = (int)nodes.size();
    if (n == 0) return;
    tree = new long long int[4 * n];
    sort(nodes.begin(), nodes.end());
    build(1, 0, n - 1);
  }
  long long int query(int node, int start, int end, int l, int r) {
    if (start >= l && end <= r) {
      return tree[node];
    }
    int mid = (start + end) >> 1;
    if (r <= mid) return query(2 * node, start, mid, l, r);
    if (l > mid) return query(2 * node + 1, mid + 1, end, l, r);
    return min(query(2 * node, start, mid, l, r),
               query(2 * node + 1, mid + 1, end, l, r));
  }
  long long int get(int l, int r) {
    int L = 0, R = n - 1;
    int left = n;
    while (L <= R) {
      int mid = (L + R) >> 1;
      if (nodes[mid].first < l) {
        L = mid + 1;
      } else {
        left = mid;
        R = mid - 1;
      }
    }
    L = 0;
    R = n - 1;
    int right = -1;
    while (L <= R) {
      int mid = (L + R) >> 1;
      if (nodes[mid].first > r) {
        R = mid - 1;
      } else {
        right = mid;
        L = mid + 1;
      }
    }
    if (left > right) return inf;
    return query(1, 0, n - 1, left, right);
  }
};
ST bag[500010];
void add(int cur, int leaf, int id) {
  long long int R = LCA::dist(cur, leaf);
  bag[cur].add(id, R);
  if (decomposed[cur] == cur) return;
  add(decomposed[cur], leaf, id);
  return;
}
long long int getanswer(int cur, int v, int l, int r) {
  long long int temp = bag[cur].get(l, r) + LCA::dist(cur, v);
  if (decomposed[cur] == cur) return temp;
  return min(temp, getanswer(decomposed[cur], v, l, r));
}
int id1[500010], g = 0;
vector<int> leaves;
void dfs(int cur, int prev = -1) {
  id1[cur] = g;
  g++;
  for (int u : adj[cur]) {
    if (u == prev) continue;
    dfs(u, cur);
  }
  if ((int)adj[cur].size() == 1 && cur != 1) leaves.emplace_back(cur);
  return;
}
int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  for (int i = 2; i <= n; i++) {
    int p;
    long long int w1;
    scanf("%d %lld", &p, &w1);
    adj[p].emplace_back(i);
    cost[p].emplace_back(w1);
    adj[i].emplace_back(p);
    cost[i].emplace_back(w1);
  }
  LCA::dfs(1);
  LCA::LCA(n);
  CD::decomposition(1, -1);
  for (int i = 1; i <= n; i++) {
    sort(adj[i].begin(), adj[i].end());
  }
  dfs(1);
  for (int u : leaves) {
    add(u, u, id1[u]);
  }
  for (int i = 1; i <= n; i++) {
    bag[i].ini();
  }
  while (q--) {
    int v, l, r;
    scanf("%d %d %d", &v, &l, &r);
    l--;
    r--;
    printf("%lld\n", getanswer(v, v, l, r));
  }
  return 0;
}
