You will be given a contest schedule for $D$ days. For each $d=1,2,\ldots,D$, calculate the satisfaction at the end of day $d$.
## Input
Input is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.
$D$
$c_1$ $c_2$ $\cdots$ $c_{26}$
$s_{1,1}$ $s_{1,2}$ $\cdots$ $s_{1,26}$
$\vdots$
$s_{D,1}$ $s_{D,2}$ $\cdots$ $s_{D,26}$
$t_1$
$t_2$
$\vdots$
$t_D$
* The constraints and generation methods for the input part are the same as those for Problem A.
* For each $d$, $t_d$ is an integer satisfying $1\leq t_d \leq 26$, and your program is expected to work correctly for any value that meets the constraints.
## Beginner's Guide
Let's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.
## Next Step
We can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each $d=1,2,\ldots,D$, we select the contest type that maximizes the satisfaction at the end of day $d$. You may have already encountered this kind of "greedy algorithms" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!
Greedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs. We can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods. For more information, please refer to the editorial that will be published after the contest.
[samples]