The Company Choir

No attempts yetTime limit1sMemory limit128 MB

Problem

Byteasar runs the in-house choir at his company. Unfortunately, he is often short of singers, because every so often a group of choir members quits and moves abroad, so he constantly has to look for new people willing to sing.

The company where Byteasar works has a very tidy organizational structure: every employee except the boss has exactly one direct supervisor. When looking for new choir members, Byteasar asks a chosen employee to prepare a list of the best-singing people among that employee's subordinates. He also requires that the voice pitch of everyone on the list fall within a given range.

Here, the "subordinates" of an employee are all employees below them in the hierarchy (directly or indirectly), and do not include the employee themselves.

Write a program that:

  • reads the description of the company and the list of questions from standard input,
  • determines the answer to each question,
  • writes the result to standard output.

Input

The first line contains two integers nn and qq (1n1000001 \le n \le 100000, 1q200001 \le q \le 20000): the number of employees and the number of questions.

Each of the next nn lines contains three integers pip_i, wiw_i, and sis_i (0pin0 \le p_i \le n, 0wi,si10000000000 \le w_i, s_i \le 1000000000). Here pip_i is the supervisor of employee ii (00 means this employee is the boss), wiw_i is their voice pitch, and sis_i is their singing ability (the higher the value, the better they sing). There is exactly one boss, and all employees have distinct singing abilities sis_i.

Each of the next qq lines contains four integers tit_i, aia_i, bib_i, and kik_i (1tin1 \le t_i \le n, 0aibi10000000000 \le a_i \le b_i \le 1000000000, 1ki10000001 \le k_i \le 1000000). This is a request for the kik_i best-singing employees among the subordinates of employee tit_i whose voice pitch lies in the range [ai,bi][a_i, b_i]. The sum of all kik_i does not exceed 100000100000.

Output

Print qq lines, one answer per question.

The answer to the ii-th question lists the numbers of the matching subordinates, from the highest singing ability to the lowest, separated by single spaces on one line. If fewer than kik_i subordinates satisfy the condition, print all of their numbers and then append a single 00.