#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n, q;
  cin >> n >> q;
  long long m = 20;
  vector<long long> parents((size_t)n, -1);
  vector<long long> weights((size_t)n, 0);
  vector<vector<long long>> children((size_t)n);
  for (long long i = 1; i < n; i++) {
    cin >> parents[i] >> weights[i];
    parents[i]--;
    children[parents[i]].push_back(i);
  }
  long long current_time = 0;
  vector<long long> times_in((size_t)n, -1), times_out((size_t)n, -1);
  vector<long long> min_leaves((size_t)n, numeric_limits<long long>::max()),
      max_leaves((size_t)n, numeric_limits<long long>::min());
  vector<vector<long long>> ancestors((size_t)m,
                                      vector<long long>((size_t)n, 0)),
      sums((size_t)m, vector<long long>((size_t)n, 0));
  vector<long long> current_stack, current_sums;
  function<void(long long)> visit = [&](long long u) {
    times_in[u] = current_time++;
    current_stack.push_back(u);
    current_sums.push_back((current_sums.empty() ? 0 : current_sums.back()) +
                           weights[u]);
    if (!children[u].empty()) {
      for (long long v : children[u]) {
        visit(v);
        min_leaves[u] = min(min_leaves[u], min_leaves[v]);
        max_leaves[u] = max(max_leaves[u], max_leaves[v]);
      }
    } else {
      min_leaves[u] = u;
      max_leaves[u] = u;
    }
    for (long long i = 0; i < m; i++) {
      if ((long long)current_stack.size() > 1 << i) {
        ancestors[i][u] = *next(current_stack.rbegin(), 1 << i);
        sums[i][u] = current_sums.back() - *next(current_sums.rbegin(), 1 << i);
      } else {
        ancestors[i][u] = 0;
        sums[i][u] = current_sums.back();
      }
    }
    current_sums.pop_back();
    current_stack.pop_back();
    times_out[u] = current_time++;
  };
  visit(0);
  auto is_ancestor = [&](long long u, long long v) {
    return times_in[u] <= times_in[v] && times_out[u] >= times_out[v];
  };
  auto lca = [&](long long u, long long v) {
    long long s = 0;
    for (long long i = m - 1; i >= 0; i--) {
      if (!is_ancestor(ancestors[i][u], v)) {
        s += sums[i][u];
        u = ancestors[i][u];
      }
    }
    for (long long i = m - 1; i >= 0; i--) {
      if (!is_ancestor(ancestors[i][v], u)) {
        s += sums[i][v];
        v = ancestors[i][v];
      }
    }
    if (!is_ancestor(u, v)) {
      s += sums[0][u];
      u = ancestors[0][u];
    }
    if (!is_ancestor(v, u)) {
      s += sums[0][v];
      v = ancestors[0][v];
    }
    return pair<long long, long long>{min(u, v), s};
  };
  vector<vector<pair<long long, long long>>> leaf_distances(
      (size_t)m, vector<pair<long long, long long>>(
                     (size_t)n, {-1, numeric_limits<long long>::max()}));
  for (long long i = 0; i < m; i++) {
    for (long long j = 0; j + (i == 0 ? 0 : (1 << (i - 1))) < n; j++) {
      if (i == 0) {
        if (children[j].empty()) {
          leaf_distances[i][j] = {j, 0};
        }
      } else {
        long long k;
        pair<long long, long long> x = leaf_distances[i - 1][j],
                                   y = leaf_distances[i - 1]
                                                     [j + (1 << (i - 1))];
        if (x.first != -1 && y.first != -1) {
          k = lca(x.first, y.first).first;
        } else if (x.first != -1) {
          k = x.first;
        } else if (y.first != -1) {
          k = y.first;
        } else {
          k = -1;
        }
        leaf_distances[i][j] = {k, numeric_limits<long long>::max()};
        if (x.first != -1) {
          leaf_distances[i][j] =
              min(leaf_distances[i][j], {k, lca(k, x.first).second + x.second});
        }
        if (y.first != -1) {
          leaf_distances[i][j] =
              min(leaf_distances[i][j], {k, lca(k, y.first).second + y.second});
        }
      }
    }
  }
  for (long long t = 0; t < q; t++) {
    long long v, l, r;
    cin >> v >> l >> r;
    v--, l--, r--;
    auto f = [&](long long x, long long y) {
      x = max(x, l), y = min(y, r);
      long long g = numeric_limits<long long>::max();
      if (x > y) {
        return g;
      }
      long long h = (long long)log2(y - x + 1);
      if (leaf_distances[h][x].first != -1) {
        g = min(g, lca(v, leaf_distances[h][x].first).second +
                       leaf_distances[h][x].second);
      }
      if (leaf_distances[h][y - (1 << h) + 1].first != -1) {
        g = min(g, lca(v, leaf_distances[h][y - (1 << h) + 1].first).second +
                       leaf_distances[h][y - (1 << h) + 1].second);
      }
      return g;
    };
    cout << min({f(l, max(min_leaves[v], l) - 1),
                 f(max(min_leaves[v], l), min(max_leaves[v], r)),
                 f(min(max_leaves[v], r) + 1, r)})
         << "\n";
  }
  return 0;
}
