E. Printer
time limit per test
4 seconds
memory limit per test
256 megabytes
input
input.txt
output
output.txt

Let's consider a network printer that functions like that. It starts working at time 0. In each second it can print one page of a text. At some moments of time the printer receives printing tasks. We know that a printer received n tasks. Let's number the tasks by consecutive integers from 1 to n. Then the task number i is characterised by three integers: ti is the time when the task came, si is the task's volume (in pages) and pi is the task's priority. The priorities of all tasks are distinct.

You are given full information about all tasks except for one: you don't know this task's priority. However, we know the time when the last page from this task was finished printing. Given this information, find the unknown priority value and determine the moments of time when the printer finished printing each task.

Input

The first line contains integer n (1 ≤ n ≤ 50000). Next n lines describe the tasks. The i-th of these lines contains three integers ti, si and pi, separated by single spaces (0 ≤ ti ≤ 109, 1 ≤ si, pi ≤ 109). Exactly one task (let's assume that his number is x) has number -1 written instead of the priority. All priorities are different. The last line contains integer T — the time when the printer finished printing the last page of task x (1 ≤ T ≤ 1015). Numbers ti are not necessarily distinct. The tasks in the input are written in the arbitrary order.

Output

In the first line print integer px — the priority of the task number x (1 ≤ px ≤ 109, remember that all priorities should be distinct). Then print n integers, the i-th of them represents the moment of time when the last page of the task number i finished printing.

It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them.

Examples
Input
34 3 -10 2 21 3 37
Output
47 8 4
Input
33 1 22 3 33 1 -14
Output
47 6 4
Note

Let's consider the first test case. Let's assume that the unknown priority equals 4, then the printer's actions for each second are as follows:

• the beginning of the 1-st second (time 0). The queue has task 2. The printer prints the first page of this task;
• the beginning of the 2-nd second (time 1). The queue has tasks 2 and 3. The printer prints the first page of task 3;
• the beginning of the 3-rd second (time 2). The queue has tasks 2 and 3. The printer prints the second page of task 3;
• the beginning of the 4-th second (time 3). The queue has tasks 2 and 3. The printer prints the third (last) page of task 3. Thus, by the end of the 4-th second this task will have been printed;
• the beginning of the 5-th second (time 4). The queue has tasks 2 and 1. The printer prints the first page of task 1;
• the beginning of the 6-th second (time 5). The queue has tasks 2 and 1. The printer prints the second page of task 1;
• the beginning of the 7-th second (time 6). The queue has tasks 2 and 1. The printer prints the third (last) page of task 1. Thus, by the end of the 7-th second this task will have been printed;
• the beginning of the 8-th second (time 7). The queue has task 2. The printer prints the second (last) page of task 2. Thus, by the end of the 8-th second this task will have been printed.

In the end, task number 1 will have been printed by the end of the 7-th second, as was required. And tasks 2 and 3 are printed by the end of the of the 8-th and the 4-th second correspondingly.