#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline long long int rand(long long int x, long long int y) {
  ++y;
  return (rng() % (y - x)) + x;
}
int n, q, r, cp[300006 + 200000], t;
long long ans;
vector<pair<int, int> > v[300006 + 200000];
vector<pair<long long int, long long int> > pos[300006 + 200000];
long long ANS[300006 + 200000];
struct node {
  int second, e, m;
  long long v;
  node *l, *r;
  node(long long int _s, long long int _e) {
    second = _s, e = _e, m = (second + e) / 2;
    v = 0;
    if (second != e) {
      l = new node(second, m);
      r = new node(m + 1, e);
    }
  }
  inline void update(long long int x, long long nv) {
    if (second == e) {
      v = nv;
      return;
    }
    if (x > m)
      r->update(x, nv);
    else
      l->update(x, nv);
    v = min(l->v, r->v);
  }
  inline long long rmq(long long int x, long long int y) {
    if (x > y) return (long long)1e18 / 10ll;
    if (second == x && e == y) return v;
    if (x > m)
      return r->rmq(x, y);
    else if (y <= m)
      return l->rmq(x, y);
    else
      return min(l->rmq(x, m), r->rmq(m + 1, y));
  }
} * seg[300006 + 200000];
int p[300006 + 200000][21], st[300006 + 200000], en[300006 + 200000], co;
long long dist[300006 + 200000];
struct lca_ {
  inline void main() {
    co = 0;
    dfs(1, 1);
    t2k();
  }
  inline void dfs(long long int x, long long int par) {
    st[x] = co++;
    p[x][0] = par;
    for (auto i : v[x]) {
      if (i.first == par) continue;
      dist[i.first] = dist[x] + i.second;
      dfs(i.first, x);
    }
    en[x] = co;
  }
  inline void t2k() {
    for (long long int j = 1; j < 21; j++)
      for (long long int i = 1; i <= n; i++) p[i][j] = p[p[i][j - 1]][j - 1];
  }
  inline long long disty(long long int x, long long int y) {
    return dist[x] + dist[y] - 2 * dist[lca(x, y)];
  }
  inline bool isp(long long int a, long long int b) {
    return st[a] <= st[b] && en[a] >= en[b];
  }
  inline long long int lca(long long int x, long long int y) {
    if (isp(x, y)) return x;
    if (isp(y, x)) return y;
    for (long long int i = 20; i >= 0; i--) {
      if (!isp(p[x][i], y)) x = p[x][i];
    }
    return p[x][0];
  }
} lca;
struct cen {
  int total = 0, sz[300006 + 200000];
  inline void main() {
    memset((sz), 0, sizeof((sz)));
    ;
    centroid(1, -1);
  }
  inline void dfs1(long long int x, long long int p) {
    total++;
    sz[x] = 1;
    for (auto i : v[x]) {
      if (i.first == p) continue;
      dfs1(i.first, x);
      sz[x] += sz[i.first];
    }
    return;
  }
  inline long long int dfs2(long long int x, long long int p) {
    for (auto i : v[x])
      if (i.first != p && sz[i.first] > total / 2) return dfs2(i.first, x);
    return x;
  }
  inline void centroid(long long int x, long long int p) {
    total = 0;
    dfs1(x, x);
    long long int cen = dfs2(x, x);
    if (p == -1) {
      r = cen;
      cp[cen] = cen;
    } else {
      cp[cen] = p;
    }
    x = cen;
    for (auto i : v[x]) {
      v[i.first].erase(find((v[i.first]).begin(), (v[i.first]).end(),
                            pair<int, int>(x, i.second)));
      centroid(i.first, x);
    }
    v[x].clear();
  }
  void go_up(long long int x, long long int o) {
    long long int d = lca.disty(x, o);
    while (pos[x].size() && pos[x].back().second >= d) pos[x].pop_back();
    pos[x].push_back(pair<long long int, long long int>(o, d));
    if (cp[x] != x) go_up(cp[x], o);
  }
  void query(long long int x, long long int o, long long int l) {
    auto itr = lower_bound((pos[x]).begin(), (pos[x]).end(),
                           pair<long long int, long long int>(l, 0)) -
               pos[x].begin();
    if (itr < pos[x].size())
      ans = min(ans, pos[x][itr].second + lca.disty(x, o));
    if (cp[x] != x) query(cp[x], o, l);
  }
} cen;
struct Qu {
  long long int x, l, i;
};
vector<Qu> Q[300006 + 200000];
bool isleaf[300006 + 200000];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> q;
  for (long long int i = 2; i < n + 1; i++) {
    long long int a, b, c;
    cin >> a >> c;
    b = i;
    v[a].push_back(pair<long long int, long long int>(b, c));
    v[b].push_back(pair<long long int, long long int>(a, c));
  }
  for (long long int i = 1; i < n + 1; i++)
    if (i != 1 && v[i].size() == 1) {
      isleaf[i] = 1;
    }
  lca.main();
  cen.main();
  for (long long int i = 0; i < q; i++) {
    long long int x, r, l;
    cin >> x >> l >> r;
    Q[r].push_back({x, l, i});
  }
  for (long long int ii = 1; ii < n + 1; ii++) {
    if (isleaf[ii]) cen.go_up(ii, ii);
    for (auto i : Q[ii]) {
      long long int x = i.x, l = i.l;
      ans = (long long)1e18;
      cen.query(x, x, l);
      ANS[i.i] = ans;
    }
  }
  for (long long int i = 0; i < q; i++) cout << ANS[i] << "\n";
}
