Let's define the Eulerian traversal of a tree (a connected undirected graph without cycles) as follows: consider a depth-first search algorithm which traverses vertices of the tree and enumerates them in the order of visiting (only the first visit of each vertex counts). This function starts from the vertex number 1 and then recursively runs from all vertices which are connected with an edge with the current vertex and are not yet visited in increasing numbers order. Formally, you can describe this function using the following pseudocode:
    
    
      
    next_id = 1  
    id = array of length n filled with -1  
    visited = array of length n filled with false  
      
    function dfs(v):  
        visited[v] = true  
        id[v] = next_id  
        next_id += 1  
        for to in neighbors of v in increasing order:  
            if not visited[to]:  
                dfs(to)  
    

You are given a weighted tree, the vertices of which were enumerated with integers from 1 to n using the algorithm described above.

A leaf is a vertex of the tree which is connected with only one other vertex. In the tree given to you, the vertex 1 is not a leaf. The distance between two vertices in the tree is the sum of weights of the edges on the simple path between them.

You have to answer q queries of the following type: given integers v, l and r, find the shortest distance from vertex v to one of the leaves with indices from l to r inclusive. 

Input

The first line contains two integers n and q (3 ≤ n ≤ 500 000, 1 ≤ q ≤ 500 000) — the number of vertices in the tree and the number of queries, respectively.

The (i - 1)-th of the following n - 1 lines contains two integers p_i and w_i (1 ≤ p_i < i, 1 ≤ w_i ≤ 10^9), denoting an edge between vertices p_i and i with the weight w_i.

It's guaranteed that the given edges form a tree and the vertices are enumerated in the Eulerian traversal order and that the vertex with index 1 is not a leaf.

The next q lines describe the queries. Each of them contains three integers v_i, l_i, r_i (1 ≤ v_i ≤ n, 1 ≤ l_i ≤ r_i ≤ n), describing the parameters of the query. It is guaranteed that there is at least one leaf with index x such that l_i ≤ x ≤ r_i.

Output

Output q integers — the answers for the queries in the order they are given in the input.

Examples

Input


5 3
1 10
1 1
3 2
3 3
1 1 5
5 4 5
4 1 2


Output


3
0
13


Input


5 3
1 1000000000
2 1000000000
1 1000000000
1 1000000000
3 4 5
2 1 5
2 4 5


Output


3000000000
1000000000
2000000000


Input


11 8
1 7
2 1
1 20
1 2
5 6
6 2
6 3
5 1
9 10
9 11
5 1 11
1 1 4
9 4 8
6 1 4
9 7 11
9 10 11
8 1 11
11 4 5


Output


8
8
9
16
9
10
0
34

Note

In the first example, the tree looks like this: 

<image>

In the first query, the nearest leaf for the vertex 1 is vertex 4 with distance 3. In the second query, the nearest leaf for vertex 5 is vertex 5 with distance 0. In the third query the nearest leaf for vertex 4 is vertex 4; however, it is not inside interval [1, 2] of the query. The only leaf in interval [1, 2] is vertex 2 with distance 13 from vertex 4.
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1ll << 60;
long long n, m, Max[500010], d[500010], L[500010], R[500010], ans[500010];
long long ver[1000010], edge[1000010], Next[1000010], head[500010], tot;
vector<long long> q[500010];
struct SegmentTree {
  long long l, r, Min, lazy;
} tree[500010 << 2];
inline long long read() {
  long long x = 0, tmp = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') tmp = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return tmp * x;
}
inline void write(long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  long long y = 10, len = 1;
  while (y <= x) {
    y = (y << 3) + (y << 1);
    len++;
  }
  while (len--) {
    y /= 10;
    putchar(x / y + 48);
    x %= y;
  }
}
inline void addEdge(long long x, long long y, long long z) {
  ver[++tot] = y;
  edge[tot] = z;
  Next[tot] = head[x];
  head[x] = tot;
}
void dfs1(long long x) {
  Max[x] = x;
  for (long long i = head[x]; i; i = Next[i]) {
    long long y = ver[i], z = edge[i];
    d[y] = d[x] + z;
    dfs1(y);
    Max[x] = max(Max[x], Max[y]);
  }
}
inline void pushup(long long p) {
  tree[p].Min = min(tree[p << 1].Min, tree[p << 1 | 1].Min);
}
inline void pushdown(long long p) {
  if (tree[p].lazy) {
    tree[p << 1].Min += tree[p].lazy;
    tree[p << 1].lazy += tree[p].lazy;
    tree[p << 1 | 1].Min += tree[p].lazy;
    tree[p << 1 | 1].lazy += tree[p].lazy;
    tree[p].lazy = 0;
  }
}
void build(long long p, long long l, long long r) {
  tree[p].l = l;
  tree[p].r = r;
  if (l == r) return;
  long long mid = (l + r) >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
}
void update(long long p, long long l, long long r, long long val) {
  if (l <= tree[p].l && tree[p].r <= r) {
    tree[p].Min += val;
    tree[p].lazy += val;
    return;
  }
  pushdown(p);
  long long mid = (tree[p].l + tree[p].r) >> 1;
  if (l <= mid) update(p << 1, l, r, val);
  if (r > mid) update(p << 1 | 1, l, r, val);
  pushup(p);
}
long long query(long long p, long long l, long long r) {
  if (l <= tree[p].l && tree[p].r <= r) return tree[p].Min;
  pushdown(p);
  long long mid = (tree[p].l + tree[p].r) >> 1, ans = INF;
  if (l <= mid) ans = min(ans, query(p << 1, l, r));
  if (r > mid) ans = min(ans, query(p << 1 | 1, l, r));
  return ans;
}
void dfs2(long long x) {
  for (long long i : q[x]) ans[i] = query(1, L[i], R[i]);
  for (long long i = head[x]; i; i = Next[i]) {
    long long y = ver[i], z = edge[i];
    update(1, 1, n, z);
    update(1, y, Max[y], -2 * z);
    dfs2(y);
    update(1, 1, n, -z);
    update(1, y, Max[y], 2 * z);
  }
}
int main() {
  n = read();
  m = read();
  for (long long i = 2; i <= n; i++) {
    long long y = read(), z = read();
    addEdge(y, i, z);
  }
  dfs1(1);
  build(1, 1, n);
  for (long long i = 1; i <= n; i++) update(1, i, i, i == Max[i] ? d[i] : INF);
  for (long long i = 1; i <= m; i++) {
    long long x = read();
    L[i] = read();
    R[i] = read();
    q[x].push_back(i);
  }
  dfs2(1);
  for (long long i = 1; i <= m; i++) {
    write(ans[i]);
    putchar('\n');
  }
  return 0;
}
