#include <bits/stdc++.h>
using namespace std;
struct E {
  long long go, nxt, w;
} e[500010];
long long head[500010], tot;
void add(long long x, long long y, long long w) {
  e[++tot].go = y;
  e[tot].nxt = head[x];
  e[tot].w = w;
  head[x] = tot;
}
long long n, q, st[1000010][30], id[1000010], pos[500010], cnt;
long long x[500010], w[500010], Min[500010], dis[500010], tail[500010], en, sum;
long long dfs(long long now) {
  dis[now] = sum;
  en = now;
  if (head[now] != 0) Min[now] = 1e18;
  id[++cnt] = now;
  pos[now] = cnt;
  for (int i = head[now]; i; i = e[i].nxt) {
    long long v = e[i].go, w = e[i].w;
    sum += w;
    Min[now] = min(Min[now], dfs(v) + w);
    sum -= w;
    id[++cnt] = now;
  }
  tail[now] = en;
  return Min[now];
}
void ST() {
  for (int j = 0; (1 << j) <= cnt; j++) {
    for (int i = 1; i + (1 << j) - 1 <= cnt; i++) {
      if (j == 0)
        st[i][0] = id[i];
      else
        st[i][j] = min(st[i][j - 1], st[i + (1 << (j - 1))][j - 1]);
    }
  }
}
long long lca(long long a, long long b) {
  a = pos[a], b = pos[b];
  if (a > b) swap(a, b);
  long long k = log2(b - a + 1);
  return min(st[a][k], st[b - (1 << k) + 1][k]);
}
long long DIS(long long a, long long b) {
  return dis[a] + dis[b] - 2 * dis[lca(a, b)];
}
long long sol(long long v, long long l, long long r) {
  long long ans = 1e18;
  for (int i = l; i <= r; i++) {
    if (tail[i] <= r) {
      ans = min(ans, DIS(v, i) + Min[i]);
      i = tail[i];
    }
  }
  if (v >= l && v <= r) {
    l = v;
    for (int i = l; i <= r; i++) {
      if (tail[i] <= r) {
        ans = min(ans, DIS(v, i) + Min[i]);
        i = tail[i];
      }
    }
  }
  return ans;
}
int main() {
  scanf("%lld%lld", &n, &q);
  for (int i = 2; i <= n; i++) {
    scanf("%lld%lld", &x[i], &w[i]);
  }
  for (int i = n; i >= 2; i--) {
    add(x[i], i, w[i]);
  }
  dfs(1);
  ST();
  for (int i = 1; i <= q; i++) {
    long long v, l, r;
    scanf("%lld%lld%lld", &v, &l, &r);
    printf("%lld\n", sol(v, l, r));
  }
  return 0;
}
