The first king of Byteland was buried with his $$$n$$$ knights a thousand years ago. In the ruins, the archaeologists have found $$$n$$$ stone tablets in a row, labeled by $$$1,2,\dots,n$$$ from left to right. Each stone tablet belongs to a knight. On the surface of the $$$k$$$-th stone tablet, five numbers describe the ability of the $$$k$$$-th knight in five aspects:
Little Q is visiting the stone tablets from left to right, according to the labels from $$$1$$$ to $$$n$$$. After visiting a stone tablet, before moving right to the next one, he can choose to take a photo with it or do nothing. Little Q estimates the value of each stone tablet, he wants to maximize the total value that he takes photos with, and the knight corresponding to the next photo always dominates the current one. Here the $$$x$$$-th knight dominates the $$$y$$$-th knight if and only if $$$w_x\geq w_y$$$, $$$g_x\geq g_y$$$, $$$i_x\geq i_y$$$, $$$f_x\geq f_y$$$ and $$$l_x\geq l_y$$$.
There are so many stone tablets that Little Q can not determine which to take photos with. Please write a program to help him.
There is only one test case in each test.
The test case starts with a line containing a single integer $$$n$$$ ($$$1 \leq n \leq 100\,000$$$), denoting the number of stone tablets.
In the next $$$n$$$ lines, the $$$k$$$-th line contains six integers $$$w_k$$$, $$$g_k$$$, $$$i_k$$$, $$$f_k$$$, $$$l_k$$$ and $$$v_k$$$ ($$$1\leq w_k,g_k,i_k,f_k,l_k\leq n$$$, $$$1\leq v_k\leq 10\,000$$$), describing the $$$k$$$-th stone tablet, $$$v_k$$$ denoting the value of the photo with it.
Output $$$n$$$ lines, the $$$k$$$-th ($$$1\leq k\leq n$$$) of which containing an integer, denoting the maximum total value when the last photo is taken with the $$$k$$$-th stone tablet.
41 2 1 2 1 302 1 2 1 2 403 3 3 3 3 502 3 3 2 4 100
30 40 90 140
| Name |
|---|


