#include <bits/stdc++.h>
using namespace std;
mt19937 rng(static_cast<unsigned int>(
    chrono::steady_clock::now().time_since_epoch().count()));
template <typename num_t>
inline void add_mod(num_t& a, const long long& b, const int& m) {
  a = (a + b) % m;
  if (a < 0) a += m;
}
template <typename num_t>
inline bool update_max(num_t& a, const num_t& b) {
  return a < b ? a = b, true : false;
}
template <typename num_t>
inline bool update_min(num_t& a, const num_t& b) {
  return a > b ? a = b, true : false;
}
template <typename num_t>
num_t gcd(num_t lhs, num_t rhs) {
  return !lhs ? rhs : gcd(rhs % lhs, lhs);
}
template <typename num_t>
num_t pw(num_t n, num_t k, const num_t& mod) {
  num_t res = 1;
  for (; k > 0; k >>= 1) {
    if (k & 1) res = 1ll * res * n % mod;
    n = 1ll * n * n % mod;
  }
  return res;
}
const int inf = 1e9 + 7;
const int mod = inf;
const long long ll_inf = 9ll * inf * inf + 7;
const int MAX_N = 500000 + 7;
long long depth[MAX_N];
vector<pair<int, int>> child[MAX_N];
template <typename num_t>
class SegmentTree {
 public:
  void init(int l, int r) {
    tree.resize((r - l + 1) << 1);
    node_index = 0;
    build_tree(tree[node_index++], l, r);
  }
  void update(int left_index, int right_index, const num_t& val) {
    if (left_index > right_index) return;
    update_(tree[0], left_index, right_index, val);
  }
  num_t get(int left_index, int right_index) {
    if (right_index < left_index) return 0;
    return get(tree[0], left_index, right_index);
  }

 private:
  struct node {
    static const num_t nil = ll_inf;
    node *left_child, *right_child;
    int left_index, right_index;
    num_t value = 0;
    num_t lazy = 0;
    inline void push_down(num_t updated_value) {
      value += updated_value;
      lazy += updated_value;
    }
    inline void merge_node() {
      const node &lhs = *left_child, &rhs = *right_child;
      value = min(lhs.value, rhs.value);
    }
    inline void lazy_update() {
      if (lazy != 0) {
        if (left_child != nullptr) left_child->push_down(lazy);
        if (right_child != nullptr) right_child->push_down(lazy);
        lazy = 0;
      }
    }
    inline void init_value(num_t v = 0) {
      int u = left_index;
      if (child[u].empty())
        value = depth[u];
      else
        value = node::nil;
    }
    inline void init(int left, int right, node* left_child_,
                     node* right_child_) {
      left_index = left;
      right_index = right;
      left_child = left_child_;
      right_child = right_child_;
    }
    int size() const { return right_index - left_index + 1; }
  };
  vector<node> tree;
  int node_index = 0;
  void build_tree(node& root, int left, int right) {
    if (left == right) {
      root.init(left, right, nullptr, nullptr);
      root.init_value(0);
      return;
    }
    int mid = (left + right) >> 1, lhs = node_index++, rhs = node_index++;
    build_tree(tree[lhs], left, mid);
    build_tree(tree[rhs], mid + 1, right);
    root.init(left, right, &tree[lhs], &tree[rhs]);
    root.merge_node();
  }
  void update_(node& root, int u, int v, const num_t& value) {
    if (u > root.right_index || v < root.left_index) return;
    if (u <= root.left_index && root.right_index <= v) {
      root.push_down(value);
    } else {
      root.lazy_update();
      update_(*root.left_child, u, v, value);
      update_(*root.right_child, u, v, value);
      root.merge_node();
    }
  }
  num_t get(node& root, int u, int v) {
    if (u <= root.left_index && root.right_index <= v) return root.value;
    if (u > root.right_index || v < root.left_index) return node::nil;
    root.lazy_update();
    auto lhs = get(*root.left_child, u, v);
    auto rhs = get(*root.right_child, u, v);
    return min(lhs, rhs);
  }
};
SegmentTree<long long> segment_tree;
long long up_cost[MAX_N];
int parent[MAX_N];
int low[MAX_N], high[MAX_N];
void dfs(int u) {
  static int cnt = 0;
  low[u] = cnt++;
  for (auto p : child[u]) {
    depth[p.first] = depth[u] + p.second;
    dfs(p.first);
  }
  high[u] = cnt;
}
struct Query {
  int id;
  int left, right;
};
vector<Query> queries[MAX_N];
long long ans[MAX_N];
int n, q;
void update_cost(int u, long long cost) {
  segment_tree.update(0, low[u] - 1, cost);
  segment_tree.update(high[u] + 1, n - 1, cost);
  segment_tree.update(low[u], high[u], -cost);
}
void process(int u) {
  update_cost(u, up_cost[u]);
  for (const Query& query : queries[u]) {
    ans[query.id] = segment_tree.get(query.left, query.right);
  }
  for (auto p : child[u]) process(p.first);
  update_cost(u, -up_cost[u]);
}
void solve() {
  cin >> n >> q;
  for (int i = 1; i < n; ++i) {
    int p, w;
    cin >> p >> w;
    child[p - 1].push_back({i, w});
    up_cost[i] = w;
  }
  dfs(0);
  segment_tree.init(0, n - 1);
  for (int i = (0), _b = (q); i < _b; ++i) {
    int u, l, r;
    cin >> u >> l >> r;
    queries[u - 1].push_back({i, l - 1, r - 1});
  }
  process(0);
  for (int i = 0; i < q; ++i) cout << ans[i] << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  const bool multiple_test = false;
  int test = 1;
  if (multiple_test) cin >> test;
  for (int i = 0; i < test; ++i) {
    solve();
  }
}
