#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
int n, q, timer = 0;
bool lst[N] = {false};
vector<pair<int, int> > G[N], LR(N);
vector<int> ans(N, 0);
vector<tuple<int, int, int> > Q[N];
int64_t t[4 * N], add[4 * N];
inline void push(int v, int vl, int vr) {
  if (add[v] != 0) {
    t[v] += add[v];
    if (vl != vr) {
      add[2 * v + 1] += add[v];
      add[2 * v + 2] += add[v];
      t[v] = min(t[2 * v + 1] + add[2 * v + 1], t[2 * v + 2] + add[2 * v + 2]);
    }
    add[v] = 0;
  }
}
inline void update(int v, int vl, int vr, int l, int r, int64_t val) {
  push(v, vl, vr);
  if (r < vl || vr < l) return;
  if (l <= vl && vr <= r) {
    add[v] += val;
    push(v, vl, vr);
    return;
  }
  int vm = vl + (vr - vl) / 2;
  update(2 * v + 1, vl, vm, l, r, val);
  update(2 * v + 2, vm + 1, vr, l, r, val);
  t[v] = min(t[2 * v + 1], t[2 * v + 2]);
}
inline int64_t get(int v, int vl, int vr, int l, int r) {
  push(v, vl, vr);
  if (r < vl || vr < l) return -1;
  if (l <= vl && vr <= r) return t[v];
  int vm = vl + (vr - vl) / 2;
  int64_t ql = get(2 * v + 1, vl, vm, l, r);
  int64_t qr = get(2 * v + 2, vm + 1, vr, l, r);
  if (ql < 0) return qr;
  if (qr < 0) return ql;
  return min(ql, qr);
}
inline void modify(int v, int vl, int vr, int pos, int64_t val) {
  if (vl == vr) {
    t[v] = val;
    return;
  }
  int vm = vl + (vr - vl) / 2;
  if (pos <= vm)
    modify(2 * v + 1, vl, vm, pos, val);
  else
    modify(2 * v + 2, vm + 1, vr, pos, val);
  t[v] = min(t[2 * v + 1], t[2 * v + 2]);
}
inline void __dfs_root(int v, int p, int64_t W) {
  timer++;
  LR[v].first = timer;
  if (G[v].size() == 1) {
    LR[v].second = timer;
    modify(1, 1, n, v, W);
    return;
  }
  for (auto to : G[v]) {
    if (to.first != p) {
      modify(1, 1, n, v, 1e18);
      __dfs_root(to.first, v, W + to.second);
    }
  }
  LR[v].second = timer;
}
inline void dfs(int v, int p) {
  for (auto u : Q[v]) {
    ans[get<0>(u)] = get(1, 1, n, get<1>(u), get<2>(u));
  }
  for (auto to : G[v]) {
    if (to.first != p) {
      int64_t W = to.second;
      update(1, 1, n, 1, n, W);
      update(1, 1, n, LR[to.first].first, LR[to.first].second, -2 * W);
      dfs(to.first, v);
      update(1, 1, n, 1, n, -W);
      update(1, 1, n, LR[to.first].first, LR[to.first].second, 2 * W);
    }
  }
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  for (int i = 2; i <= n; i++) {
    int p, w;
    cin >> p >> w;
    G[p].push_back(make_pair(i, w));
    G[i].push_back(make_pair(p, w));
  }
  for (int i = 0; i < q; i++) {
    int v, l, r;
    cin >> v >> l >> r;
    if (l > r) swap(l, r);
    Q[v].push_back(make_tuple(i, l, r));
  }
  __dfs_root(1, -1, 0);
  dfs(1, -1);
  for (int i = 0; i < q; i++) cout << ans[i] << '\n';
  return 0;
}
