#include <bits/stdc++.h>
const int maxn = 5e5 + 5;
std::vector<std::pair<int, int>> G[maxn];
std::vector<std::tuple<int, int, int>> q[maxn];
int in[maxn], out[maxn], id[maxn], tot, n, m;
long long dis[maxn], ans[maxn];
struct SegTree {
  long long sum[maxn << 2], lazy[maxn << 2];
  void pushdown(int o) {
    if (lazy[o]) {
      sum[o << 1] += lazy[o];
      sum[o << 1 | 1] += lazy[o];
      lazy[o << 1] += lazy[o];
      lazy[o << 1 | 1] += lazy[o];
      lazy[o] = 0;
    }
  }
  void build(int o, int l, int r) {
    if (l == r) {
      sum[o] = dis[l];
      return;
    }
    int m = (l + r) >> 1;
    build(o << 1, l, m);
    build(o << 1 | 1, m + 1, r);
    sum[o] = std::min(sum[o << 1], sum[o << 1 | 1]);
  }
  void update(int o, int l, int r, int ql, int qr, int val) {
    if (ql <= l && r <= qr) {
      sum[o] += val;
      lazy[o] += val;
      return;
    }
    int m = (l + r) >> 1;
    pushdown(o);
    if (ql <= m) update(o << 1, l, m, ql, qr, val);
    if (qr > m) update(o << 1 | 1, m + 1, r, ql, qr, val);
    sum[o] = std::min(sum[o << 1], sum[o << 1 | 1]);
  }
  long long query(int o, int l, int r, int ql, int qr) {
    if (ql <= l && r <= qr) {
      return sum[o];
    }
    int m = (l + r) >> 1;
    long long ans = 0x3f3f3f3f3f3f3f3f;
    pushdown(o);
    if (ql <= m) ans = std::min(ans, query(o << 1, l, m, ql, qr));
    if (qr > m) ans = std::min(ans, query(o << 1 | 1, m + 1, r, ql, qr));
    return ans;
  }
} st;
void dfs1(int u, long long d) {
  in[u] = ++tot;
  for (auto &it : G[u]) dfs1(it.first, it.second + d);
  if (G[u].empty())
    dis[u] = d;
  else
    dis[u] = 0x3f3f3f3f3f3f3f3f;
  out[u] = tot;
}
void dfs2(int u, long long d) {
  for (auto &it : q[u])
    ans[std::get<2>(it)] =
        st.query(1, 1, n, std::get<0>(it), std::get<1>(it)) + d;
  for (auto &it : G[u]) {
    st.update(1, 1, n, in[it.first], out[it.first], -2 * it.second);
    dfs2(it.first, it.second + d);
    st.update(1, 1, n, in[it.first], out[it.first], 2 * it.second);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 2; i <= n; i++) {
    int u, w;
    scanf("%d%d", &u, &w);
    G[u].emplace_back(i, w);
  }
  dfs1(1, 0);
  st.build(1, 1, n);
  for (int i = 1; i <= m; i++) {
    int v, l, r;
    scanf("%d%d%d", &v, &l, &r);
    q[v].emplace_back(l, r, i);
  }
  dfs2(1, 0);
  for (int i = 1; i <= m; i++) printf("%lld\n", ans[i]);
  return 0;
}
