#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &a) {
  in >> a.first >> a.second;
  return in;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &out, pair<T1, T2> a) {
  out << a.first << " " << a.second;
  return out;
}
template <typename T, typename T1>
T maxs(T &a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T mins(T &a, T1 b) {
  if (b < a) a = b;
  return a;
}
struct node {
  long long a = 0;
  node(long long val = 0) { a = val; }
  void merge(node &n1, node &n2) { this->a = min(n1.a, n2.a); }
} nul;
template <typename node>
struct segtree {
  node *t;
  long long *tl;
  long long *tr;
  void resize(long long n) {
    t = new node[4 * n];
    tl = new long long[4 * n];
    tr = new long long[4 * n];
  }
  void build(long long v, long long start, long long end,
             vector<long long> &arr) {
    tl[v] = start;
    tr[v] = end;
    if (start == end) {
      t[v].a = arr[start];
    } else {
      long long m = (start + end) / 2;
      build(2 * v, start, m, arr);
      build(2 * v + 1, m + 1, end, arr);
      t[v].merge(t[2 * v], t[2 * v + 1]);
    }
  }
  node query(long long v, long long l, long long r) {
    if (tr[v] < l || tl[v] > r) return nul;
    if (l <= tl[v] && tr[v] <= r) {
      return t[v];
    }
    node a = query(2 * v, l, r);
    node b = query(2 * v + 1, l, r);
    node ans;
    ans.merge(a, b);
    return ans;
  }

 public:
  node query(long long l, long long r) { return query(1, l, r); }
};
const long long maxn = 500005;
set<pair<long long, long long> > g[maxn];
long long p[maxn];
long long b_p[maxn][21];
long long level[maxn];
long long lvl2[maxn];
long long dp[maxn][21];
vector<long long> leaves;
void dfs(long long n, long long e, long long l) {
  p[n] = e;
  level[n] = l;
  if (g[n].size() == 1) leaves.push_back(n);
  for (auto i : g[n]) {
    if (i.first != e) {
      lvl2[i.first] = lvl2[n] + 1;
      long long w = i.second;
      dfs(i.first, n, l + w);
    }
  }
  return;
}
void lift(long long n) {
  for (long long i = 0; i <= 20; i++) {
    for (long long j = 1; j <= n; j++) {
      if (i == 0)
        b_p[j][i] = p[j];
      else
        b_p[j][i] = b_p[b_p[j][i - 1]][i - 1];
    }
  }
  return;
}
long long lca(long long u, long long v) {
  if (lvl2[v] < lvl2[u]) u = v + u - (v = u);
  long long diff = lvl2[u] - lvl2[v];
  for (long long i = 20; i >= 0; i--) {
    if (lvl2[v] - lvl2[u] >= (1 << i)) {
      v = b_p[v][i];
    }
  }
  if (v == u) {
    return u;
  }
  long long k = ceil(log2(lvl2[u]));
  while (k >= 0) {
    if (b_p[u][k] != b_p[v][k]) {
      u = b_p[u][k];
      v = b_p[v][k];
    }
    k--;
  }
  return p[u];
}
long long d(long long u, long long v) {
  return level[u] + level[v] - 2 * level[lca(u, v)];
}
long long ctree[maxn];
long long sz[maxn];
long long temp = 0;
vector<long long> cen[maxn];
vector<long long> temp2;
void dfs1(long long u, long long par) {
  sz[u] = 1;
  temp++;
  for (auto i : g[u]) {
    if (i.first != par) {
      dfs1(i.first, u);
      sz[u] += sz[i.first];
    }
  }
}
long long dfs2(long long u, long long par) {
  for (auto i : g[u]) {
    if (i.first != par && sz[i.first] > temp / 2) {
      return dfs2(i.first, u);
    }
  }
  return u;
}
void decompose(long long u, long long par) {
  temp = 0;
  dfs1(u, u);
  long long centroid = dfs2(u, u);
  if (par <= 0) par = centroid;
  ctree[centroid] = par;
  for (auto i : g[centroid]) {
    g[i.first].erase({centroid, i.second});
    decompose(i.first, centroid);
  }
  g[centroid].clear();
}
segtree<node> seg[maxn];
void process(long long n) {
  for (auto i : leaves) {
    long long first = i;
    while (1) {
      cen[first].push_back(i);
      if (first == ctree[first]) break;
      first = ctree[first];
    }
  }
  for (long long i = 1; i <= n; i++) {
    if (cen[i].empty()) continue;
    vector<long long> temp;
    sort(cen[i].begin(), cen[i].end());
    for (auto j : cen[i]) temp.push_back(d(i, j));
    seg[i].resize((long long)temp.size());
    seg[i].build(1, 0, (long long)temp.size() - 1, temp);
  }
}
long long query(long long first, long long l, long long r) {
  long long u = first;
  long long mi = 1e18;
  while (1) {
    long long val = d(first, u);
    if (cen[u].empty() || cen[u].front() > r || cen[u].back() < l) {
      if (u == ctree[u] || ctree[u] == 0) break;
      u = ctree[u];
    } else {
      long long l2 =
          lower_bound(cen[u].begin(), cen[u].end(), l) - cen[u].begin();
      long long r2 =
          upper_bound(cen[u].begin(), cen[u].end(), r) - cen[u].begin();
      r2--;
      mins(mi, val + seg[u].query(l2, r2).a);
      if (u == ctree[u] || ctree[u] == 0) break;
      u = ctree[u];
    }
  }
  return mi;
}
long long solve() {
  long long n, q;
  cin >> n >> q;
  for (long long i = 0; i < n - 1; i++) {
    long long p, w;
    cin >> p >> w;
    g[i + 2].insert({p, w});
    g[p].insert({i + 2, w});
  }
  dfs(1, 0, 0);
  lift(n);
  decompose(1, -1);
  process(n);
  for (long long i = 1; i <= q; i++) {
    long long v, l, r;
    cin >> v >> l >> r;
    cout << query(v, l, r) << "\n";
  }
  return 0;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  nul.a = 1000000007;
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
