{"raw_statement":[{"iden":"statement","content":"Once Gustave is happy with the final string he gets, he contacts a company to have the string printed on a strip of fabric. Being meticulous, Gustave does not want the company to make a single mistake. He thus computes a checksum out of his string and has the company do the same computation as a verification.\n\nThe input consists of the following lines: \n\n*Limits* \n\nThe output should consist of a single line, whose content is an integer, the sum of all ASCII codes of the characters of the final string $S (N -1)$ , modulo $1000000007$.\n\n"},{"iden":"input","content":"The input consists of the following lines:   The first line contains an integer $N$.  The next line contains a string $S (0)$ of lowercase alphabetic characters between 'a' and 'z'.  The next $N -1$ lines contain instructions to build strings $S (1), \\\\dots, S (N -1)$ . The instruction to build string $S (i)$ is either:   \"SUB $x$ $l o$ $h i$\" with $x$, $l o$, $h i$ integers such that $0 <= x < i$ and $0 <= l o <= h i <= l e n g t h (S (x)$), or  \"APP $x$ $y$\" with $x$, $y$ integers such that $0 <= x, y < i$.  Instruction \"SUB $x$ $l o$ $h i$\" means that $S (i)$ is formed using (a copy of) characters of $S (x)$ from index $l o$ (inclusive) to $h i$ (exclusive). Characters are numbered starting from 0. Instruction \"APP $x$ $y$\" means that $S (i)$ is formed by concatenating copies of strings $S (x)$ and $S (y)$ in that order, i.e., with $S (x)$ coming first then $S (y)$ . *Limits*   $1 <= N <= 2500$;  $1 <= l e n g t h (S (0)) <= 1000$;  the length of any string $S (i)$ will never exceed $2^(63) -1$. "},{"iden":"output","content":"The output should consist of a single line, whose content is an integer, the sum of all ASCII codes of the characters of the final string $S (N -1)$ , modulo $1000000007$."}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ S $ be the final string.  \n\n**Objective**  \nCompute:  \n$$\n\\left( \\sum_{c \\in S} \\text{ASCII}(c) \\right) \\bmod 1000000007\n$$","simple_statement":"Compute the sum of ASCII values of all characters in the final string S, modulo 1000000007.","has_page_source":false}