#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
const long long inf = 1e18;
long long f[N][20], g[N][20], T[N][20], d[N];
int lg[N], fa[N][20], in[N], out[N], cur[N];
int n, Q, a, b, c;
vector<int> e[N], w[N];
long long ans;
int clk;
void dfs(int u, int father) {
  fa[u][0] = father;
  in[u] = ++clk;
  if (e[u].size() == 0)
    T[in[u]][0] = d[u];
  else
    T[in[u]][0] = inf;
  for (int k = (0); k < (e[u].size()); k++)
    if (e[u][k] != father) {
      d[e[u][k]] = d[u] + w[u][k];
      dfs(e[u][k], u);
    }
  out[u] = clk;
}
inline long long qry(int l, int r) {
  if (l > r) return inf;
  int tmp = lg[r - l + 1];
  return min(T[l][tmp], T[r - (1 << tmp) + 1][tmp]);
}
void init() {
  lg[0] = -1;
  for (int i = (1); i <= (n); i++) lg[i] = lg[i >> 1] + 1;
  for (int j = (1); j <= (19); j++)
    for (int i = (1); i <= (n); i++) {
      T[i][j] = T[i][j - 1];
      if (i + (1 << (j - 1)) <= n)
        T[i][j] = min(T[i][j], T[i + (1 << (j - 1))][j - 1]);
    }
  f[0][0] = g[0][0] = inf;
  f[1][0] = g[1][0] = inf;
  in[0] = 0, out[0] = clk + 1;
  for (int i = (1); i <= (n); i++) {
    long long best = inf;
    for (int k = (0); k < (e[i].size()); k++)
      if (e[i][k] != fa[i][0]) {
        f[e[i][k]][0] = best - 2 * d[i];
        best = min(best, qry(in[e[i][k]], out[e[i][k]]));
      }
    best = inf;
    for (int k = (e[i].size() - 1); k >= (0); k--)
      if (e[i][k] != fa[i][0]) {
        g[e[i][k]][0] = best - 2 * d[i];
        best = min(best, qry(in[e[i][k]], out[e[i][k]]));
      }
  }
  for (int j = (1); j <= (19); j++)
    for (int i = (0); i <= (n); i++) {
      fa[i][j] = fa[fa[i][j - 1]][j - 1];
      f[i][j] = min(f[i][j - 1], f[fa[i][j - 1]][j - 1]);
      g[i][j] = min(g[i][j - 1], g[fa[i][j - 1]][j - 1]);
    }
}
inline long long calc(int x, int l, int r, int y) {
  if (!y) y = 1;
  l = max(l, in[y]), r = min(r, out[y]);
  return qry(l, r) + d[x] - 2 * d[y];
}
long long doitL(int x, int l, int r) {
  if (l > r) return inf;
  long long ans = inf;
  int first = x, la = x;
  for (int j = (19); j >= (0); j--)
    if (in[fa[first][j]] > r) first = fa[first][j];
  if (in[first] > r) first = fa[first][0];
  for (int j = (19); j >= (0); j--)
    if (l < in[fa[la][j]]) la = fa[la][j];
  if (l < in[la]) la = fa[la][0];
  ans = min(ans, calc(x, l, r, first));
  ans = min(ans, calc(x, l, r, la));
  if (la != first) {
    for (int j = (19); j >= (0); j--)
      if (d[fa[first][j]] > d[la]) {
        ans = min(ans, f[first][j]);
        first = fa[first][j];
      }
  }
  return ans;
}
long long doitR(int x, int l, int r) {
  if (l > r) return inf;
  long long ans = inf;
  int first = x, la = x;
  for (int j = (19); j >= (0); j--)
    if (out[fa[first][j]] < l) first = fa[first][j];
  if (out[first] < l) first = fa[first][0];
  for (int j = (19); j >= (0); j--)
    if (r > out[fa[la][j]]) la = fa[la][j];
  if (r > out[la]) la = fa[la][0];
  ans = min(ans, calc(x, l, r, first));
  ans = min(ans, calc(x, l, r, la));
  if (la != first) {
    for (int j = (19); j >= (0); j--)
      if (d[fa[first][j]] > d[la]) {
        ans = min(ans, g[first][j]);
        first = fa[first][j];
      }
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &Q);
  for (int i = (2); i <= (n); i++) {
    scanf("%d%d", &a, &b);
    e[a].push_back(i);
    w[a].push_back(b);
  }
  dfs(1, 0);
  init();
  while (Q--) {
    scanf("%d%d%d", &a, &b, &c);
    if (e[a].size() == 0 && b <= in[a] && in[a] <= c)
      puts("0");
    else
      printf("%lld\n",
             min(doitL(a, b, min(c, in[a])), doitR(a, max(b, in[a]), c)));
  }
  return 0;
}
