{"raw_statement":[{"iden":"statement","content":"Ben found an old game box in his grandfather's basement and is looking forward to having $A G M$ (A Great Moment) playing it. In the box he found a game table with $12$ rows ($9 -12$ are extra) and $6$ columns, $7$ types of pieces (which we will further call I, O, L, J, T, S, Z), and a description of the game:\n\nFind below a description of each game piece. Notice how each of them fits into a $4 times 4$ square matrix. Each black square represents an element of the piece. We'll consider the origin of each piece, the top left corner of this matrix. A rotation of ONE step corresponds to a transition between adjacent states of the same piece. \n\nBen wonders what is the maximum possible score that can be achieved by correctly using a given set of pieces. Can you help Ben out? \n\nThe first line of the input contains the number of game pieces $N$ ($1 <= N <= 5$).\n\nThe second line contains a string of length $N$ containing the game pieces.\n\nThe following $8$ lines, each contain a string length $6$. The character '.' signifies an open position on the game table, while the character '#' signifies an unavailable position on the game table. No other characters are used.\n\nThe output file should contain one integer representing the maximum possible score which can be obtained through strategic and well planned $A G M$s (A Great Moments).\n\n"},{"iden":"input","content":"The first line of the input contains the number of game pieces $N$ ($1 <= N <= 5$).The second line contains a string of length $N$ containing the game pieces.The following $8$ lines, each contain a string length $6$. The character '.' signifies an open position on the game table, while the character '#' signifies an unavailable position on the game table. No other characters are used."},{"iden":"output","content":"The output file should contain one integer representing the maximum possible score which can be obtained through strategic and well planned $A G M$s (A Great Moments)."}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ A = (a_1, a_2, \\dots, a_n) \\in \\mathbb{Z}^n $ be the initial array.  \nLet $ \\mathcal{H}(A) $ denote Vasya’s hash function, defined recursively as:  \n- If $ |A| = 1 $, then $ \\mathcal{H}(A) = a_1 $.  \n- If $ |A| \\geq 2 $, then $ \\mathcal{H}(A) = \\mathcal{H}((a_2 - a_1, a_3, \\dots, a_n)) $.  \n\n**Constraints**  \n1. $ 1 \\leq n \\leq 500000 $  \n2. $ -10^9 \\leq a_i \\leq 10^9 $ for all $ i \\in \\{1, \\dots, n\\} $  \n3. $ 1 \\leq q \\leq 200000 $  \n4. For each operation $ j $:  \n   - $ 1 \\leq l_j \\leq r_j \\leq n $  \n   - $ -10^9 \\leq v_j \\leq 10^9 $  \n\n**Objective**  \nFor each operation $ j \\in \\{1, \\dots, q\\} $:  \n- Update the array: $ a_i \\leftarrow a_i + v_j $ for all $ i \\in [l_j, r_j] $.  \n- Compute and output $ \\mathcal{H}(A) $ after the update.  \n\n**Key Insight**  \nIt can be shown that:  \n$$\n\\mathcal{H}(A) = \\sum_{i=1}^{n} (-1)^{i-1} a_i\n$$","simple_statement":"Given an array, repeatedly replace the first two elements a1, a2 with a2 - a1 until one element remains. That final element is the hash. After each update (adding v to a range [l, r]), output the new hash.","has_page_source":false}