#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  x = 0;
  char c = getchar();
  int fh = 1;
  while (!isdigit(c)) {
    if (c == '-') fh = -1;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  x *= fh;
}
int n, q, f[500010][22], le[500010], ri[500010], x, l1, r1;
bool vi[500010];
struct seg {
  int l, r;
  long long ma;
} t[500010 * 4];
long long d[500010], ansn, sum, l[500010][22], r[500010][22];
void build(int nu, int l, int r) {
  t[nu].l = l;
  t[nu].r = r;
  if (l == r) {
    if (vi[l])
      t[nu].ma = d[l];
    else
      t[nu].ma = 1e18;
  } else {
    build(nu * 2, l, (l + r) / 2);
    build(nu * 2 + 1, (l + r) / 2 + 1, r);
    t[nu].ma = min(t[nu * 2].ma, t[nu * 2 + 1].ma);
  }
}
long long quem(int nu, int l, int r) {
  if (l > r) return 1e18;
  if (t[nu].l == l && t[nu].r == r) return t[nu].ma;
  int mid = (t[nu].l + t[nu].r) / 2;
  if (l > mid) return quem(nu * 2 + 1, l, r);
  if (r <= mid) return quem(nu * 2, l, r);
  return min(quem(nu * 2, l, mid), quem(nu * 2 + 1, mid + 1, r));
}
bool jiao(int x, int l, int r) {
  if (r < le[x] || ri[x] < l) return 0;
  return 1;
}
int que(int nu, int l, int r) {
  int an = 0;
  for (int i = 20; i >= 0; i--) {
    if (!jiao(f[nu][i], l, r)) {
      nu = f[nu][i];
      an += (1 << i);
    }
  }
  return an;
}
void fa(int &x, int d) {
  for (int i = 20; i >= 0; i--)
    if ((d & (1 << i)) != 0) x = f[x][i];
}
long long quel(int x, int l1) {
  long long ansn = 1e18;
  for (int i = 20; i >= 0; i--) {
    if (le[f[x][i]] > l1) {
      ansn = min(ansn, l[x][i]);
      x = f[x][i];
    }
  }
  ansn = min(ansn, quem(1, l1, le[x] - 1) - d[f[x][0]] * 2);
  return ansn;
}
long long quer(int x, int r1) {
  long long ansn = 1e18;
  for (int i = 20; i >= 0; i--) {
    if (ri[f[x][i]] < r1) {
      ansn = min(ansn, r[x][i]);
      x = f[x][i];
    }
  }
  ansn = min(ansn, quem(1, ri[x] + 1, r1) - d[f[x][0]] * 2);
  return ansn;
}
int main() {
  read(n);
  read(q);
  d[1] = 0;
  for (int i = 1; i <= n; i++) vi[i] = 1;
  for (int i = 2; i <= n; i++) {
    read(f[i][0]);
    vi[f[i][0]] = 0;
    read(x);
    d[i] = d[f[i][0]] + x;
  }
  build(1, 1, n);
  for (int i = n; i >= 1; i--) {
    le[i] = i;
    ri[i] = i;
  }
  le[0] = 1;
  ri[0] = n;
  for (int i = n; i > 1; i--) ri[f[i][0]] = max(ri[f[i][0]], ri[i]);
  for (int i = 1; i <= n; i++) {
    l[i][0] = quem(1, le[f[i][0]], le[i] - 1) - d[f[i][0]] * 2;
    r[i][0] = quem(1, ri[i] + 1, ri[f[i][0]]) - d[f[i][0]] * 2;
  }
  for (int i = 2, j = 1; i <= n; i *= 2, j++)
    for (int k = 1; k <= n; k++) {
      f[k][j] = f[f[k][j - 1]][j - 1];
      l[k][j] = max(l[k][j - 1], l[f[k][j - 1]][j - 1]);
      r[k][j] = max(r[k][j - 1], r[f[k][j - 1]][j - 1]);
    }
  while (q--) {
    read(x);
    read(l1);
    read(r1);
    ansn = d[x], sum = 1e18;
    int di = que(x, l1, r1);
    if (!jiao(x, l1, r1)) fa(x, di + 1);
    sum = min(sum, quem(1, max(l1, le[x]), min(r1, ri[x])) - d[x] * 2);
    if (l1 < le[x]) sum = min(sum, quel(x, l1));
    if (r1 > ri[x]) sum = min(sum, quer(x, r1));
    printf("%I64d\n", sum + ansn);
  }
  return 0;
}
