#include <bits/stdc++.h>
using namespace std;
int power(int x, int y) {
  int res = 1;
  while (y) {
    if (y & 1) res = (res * x) % 1000000007;
    y = y / 2, x = (x * x) % 1000000007;
  }
  return res % 1000000007;
}
vector<int> leaf;
vector<vector<pair<int, int> > > arr(500001);
long long seg[4 * 500001];
long long lazy[4 * 500001];
int id = 1;
vector<vector<pair<int, pair<int, int> > > > query(500001);
long long ans[500001];
int cntleaf = 0;
pair<int, int> range[500001];
int n, q;
void push(int index, int low, int high) {
  if (seg[index] == 1e18)
    seg[index] = lazy[index];
  else
    seg[index] += lazy[index];
  if (low != high)
    lazy[2 * index] += lazy[index], lazy[2 * index + 1] += lazy[index];
  lazy[index] = 0;
  return;
}
void update(int low, int high, int index, int l, int r, long long val) {
  if (low > high or l > r) return;
  if (lazy[index] != 0) push(index, low, high);
  if (low > r or high < l) return;
  if (low >= l and high <= r) {
    lazy[index] += val;
    push(index, low, high);
    return;
  }
  int mid = (low + high) / 2;
  update(low, mid, 2 * index, l, r, val);
  update(mid + 1, high, 2 * index + 1, l, r, val);
  seg[index] = min(seg[2 * index], seg[2 * index + 1]);
}
long long qqqq(int low, int high, int index, int l, int r) {
  if (low > high or l > r) return 1e18;
  if (lazy[index] != 0) push(index, low, high);
  if (low > r or high < l) return 1e18;
  if (low >= l and high <= r) return seg[index];
  int mid = (low + high) / 2;
  long long val1 = qqqq(low, mid, 2 * index, l, r);
  long long val2 = qqqq(mid + 1, high, 2 * index + 1, l, r);
  seg[index] = min(val1, val2);
  return seg[index];
}
pair<int, int> dfs(int u, int par, long long dist) {
  pair<int, int> temp;
  temp.first = 1e7, temp.second = -1e7;
  if (arr[u].size() == 1) {
    temp.first = cntleaf, temp.second = cntleaf;
    range[u] = temp;
    leaf.push_back(id);
    id++;
    update(0, n - 1, 1, cntleaf, cntleaf, dist);
    cntleaf++;
    return temp;
  }
  id++;
  int i;
  for (i = 0; i < arr[u].size(); i++) {
    int v = arr[u][i].first;
    if (v != par) {
      pair<int, int> lol = dfs(v, u, dist + (arr[u][i].second * 1LL));
      temp.first = min(temp.first, lol.first);
      temp.second = max(temp.second, lol.second);
    }
  }
  range[u] = temp;
  return temp;
}
int equivalent1(int pos) {
  int low = 0;
  int high = cntleaf - 1;
  int ans = high;
  while (low <= high) {
    int mid = (low + high) / 2;
    if (leaf[mid] >= pos) {
      ans = mid, high = mid - 1;
    } else
      low = mid + 1;
  }
  return ans;
}
int equivalent2(int pos) {
  int low = 0, high = cntleaf - 1;
  int ans = 0;
  while (low <= high) {
    int mid = (low + high) / 2;
    if (leaf[mid] <= pos) {
      ans = mid, low = mid + 1;
    } else
      high = mid - 1;
  }
  return ans;
}
int dfsans(int u, int par) {
  int i;
  for (i = 0; i < query[u].size(); i++) {
    int l = query[u][i].first;
    int r = query[u][i].second.first;
    int index = query[u][i].second.second;
    int lll = equivalent1(l);
    int rr = equivalent2(r);
    ans[index] = qqqq(0, n - 1, 1, lll, rr);
  }
  for (i = 0; i < arr[u].size(); i++) {
    int v = arr[u][i].first;
    if (v != par) {
      int w = arr[u][i].second;
      update(0, n - 1, 1, range[v].first, range[v].second, w * -1);
      update(0, n - 1, 1, 0, range[v].first - 1, w);
      update(0, n - 1, 1, range[v].second + 1, cntleaf - 1, w);
      dfsans(v, u);
      update(0, n - 1, 1, range[v].first, range[v].second, w);
      update(0, n - 1, 1, 0, range[v].first - 1, w * -1);
      update(0, n - 1, 1, range[v].second + 1, cntleaf - 1, w * -1);
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  int i;
  for (i = 2; i <= n; i++) {
    int p, w;
    cin >> p >> w;
    arr[p].push_back(make_pair(i, w));
    arr[i].push_back(make_pair(p, w));
  }
  for (i = 0; i <= 4 * n; i++) seg[i] = 1e18, lazy[i] = 0;
  for (i = 1; i <= n; i++) sort(arr[i].begin(), arr[i].end());
  for (i = 0; i < q; i++) {
    int v, l, r;
    cin >> v >> l >> r;
    query[v].push_back(make_pair(l, make_pair(r, i)));
  }
  dfs(1, 0, 0);
  dfsans(1, 0);
  for (i = 0; i < q; i++) cout << ans[i] << "\n";
}
