#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int rand(int x, 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<int> pos[300006 + 200000];
struct node {
  int second, e, m;
  long long v;
  node *l, *r;
  node(int _s, 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);
    }
  }
  void update(int x, int 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);
  }
  long long rmq(int x, 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_ {
  void main() {
    co = 0;
    dfs(1, 1);
    t2k();
  }
  void dfs(int x, 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;
  }
  void t2k() {
    for (int j = 1; j < 21; j++)
      for (int i = 1; i <= n; i++) p[i][j] = p[p[i][j - 1]][j - 1];
  }
  long long disty(int x, int y) {
    return dist[x] + dist[y] - 2 * dist[lca(x, y)];
  }
  bool isp(int a, int b) { return st[a] <= st[b] && en[a] >= en[b]; }
  int lca(int x, int y) {
    if (isp(x, y)) return x;
    if (isp(y, x)) return y;
    for (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];
  void main() {
    memset((sz), 0, sizeof((sz)));
    ;
    centroid(1, -1);
  }
  void dfs1(int x, 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;
  }
  int dfs2(int x, int p) {
    for (auto i : v[x])
      if (i.first != p && sz[i.first] > total / 2) return dfs2(i.first, x);
    return x;
  }
  void centroid(int x, int p) {
    total = 0;
    dfs1(x, x);
    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(int x, int o, bool up = 0) {
    if (up)
      seg[x]->update(
          lower_bound((pos[x]).begin(), (pos[x]).end(), o) - pos[x].begin(),
          lca.disty(x, o));
    else
      pos[x].push_back(o);
    if (cp[x] != x) go_up(cp[x], o, up);
  }
  void init(int x) {
    sort((pos[x]).begin(), (pos[x]).end());
    if (pos[x].size()) seg[x] = new node(0, pos[x].size() - 1);
  }
  void query(int x, int o, int l, int r) {
    if (pos[x].size())
      ans = min(ans,
                seg[x]->rmq(lower_bound((pos[x]).begin(), (pos[x]).end(), l) -
                                pos[x].begin(),
                            upper_bound((pos[x]).begin(), (pos[x]).end(), r) -
                                pos[x].begin() - 1) +
                    lca.disty(x, o));
    if (cp[x] != x) query(cp[x], o, l, r);
  }
} cen;
void in(int& x) {
  char c = getchar();
  while (c < 48 && c > 57) c = getchar();
  x = 0;
  while (c >= 48 && c <= 57) {
    x = x * 10 + c - 48;
    c = getchar();
  }
}
vector<int> l;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  in(n);
  in(q);
  for (int i = 2; i < n + 1; i++) {
    int a, b, c;
    in(a);
    in(c);
    b = i;
    v[a].push_back(pair<int, int>(b, c));
    v[b].push_back(pair<int, int>(a, c));
  }
  for (int i = 1; i < n + 1; i++)
    if (v[i].size() == 1 && i != 1) l.push_back(i);
  lca.main();
  cen.main();
  for (auto i : l) cen.go_up(i, i);
  for (int i = 1; i < n + 1; i++) cen.init(i);
  for (auto i : l) cen.go_up(i, i, 1);
  for (int i = 0; i < q; i++) {
    ans = (long long)1e18;
    int v, l, r;
    in(v);
    in(l);
    in(r);
    cen.query(v, v, l, r);
    cout << ans << "\n";
  }
}
