Little S really likes playing board games, especially Splendor. Now he has simplified and modified the rules.
The game includes the following components:
At the beginning of the game, the top $$$4$$$ cards (cards $$$1$$$ to $$$4$$$) of the deck are revealed on the table to serve as the initial exchangeable cards. The remaining cards in the deck are now cards $$$5$$$ through $$$n$$$.
In each turn, you may perform exactly one of the following three operations:
Whenever you successfully exchange an exchangeable card on the table:
Your goal is to empty the deck. Note that there may still be some exchangeable cards left on the table at this point; this situation is also considered a successful completion of the goal. Please calculate the minimum number of turns required to achieve this goal.
The first line contains an integer $$$n$$$ ($$$4\le n\le 100$$$).
For the next $$$n$$$ lines, the $$$i$$$-th line contains $$$6$$$ integers, respectively $$$c_i$$$, $$$p_{i,1}$$$, $$$p_{i,2}$$$, $$$p_{i,3}$$$, $$$p_{i,4}$$$, $$$p_{i,5}$$$ ($$$1 \le c_i \le 5$$$, $$$0 \le p_{i,j} \le 10^9$$$), indicating the color of the $$$i$$$-th card and the number of chips required.
Output an integer representing the minimum number of turns.
51 4 1 1 7 11 2 2 8 4 81 2 3 6 7 21 6 5 7 3 11 9 9 9 9 9
7
72 15 34 0 15 244 11 20 0 18 01 4 0 2 48 203 17 0 8 43 701 0 58 7 1 521 64 0 81 40 02 4 0 0 0 10
86
For the first example: For the first four cards, it takes $$$6$$$, $$$8$$$, $$$7$$$, and $$$8$$$ operations, respectively, to accumulate the required number of chips through chip-taking operations.
The optimal strategy is: First, spend $$$6$$$ moves to collect chips to meet the requirement of the first card, then use the $$$7$$$-th move to "exchange cards". After the exchange is complete, the $$$5$$$-th card (the last one) in the deck is placed on the table, at which point the deck is empty. This takes a total of $$$7$$$ moves.
The specific steps are as follows:
| Название |
|---|


