P7350 "MCOI-04" Dream and Strings

Description

Tommy’s encryption system uses the following string hash algorithm: ```cpp int Hash(std::string s, int base, int mod) { int result = 0; for(int i=0; i

Input Format

The first line contains two positive integers $\texttt{base}$ and $\texttt{mod}$. The second line contains a string $S$ consisting of lowercase letters.

Output Format

Output one line containing a string $T$ consisting of lowercase letters, representing the answer.

Explanation/Hint

#### Constraints If $S$ is a string, $|S|$ is its length. For the first $10\%$ of the testdata, $\texttt{mod}=997$. For the first $40\%$ of the testdata, $|S|=2\times10^5$ and $S$ is random. For $100\%$ of the testdata, $50\le|S|\le2\times10^5$, $257\le\texttt{base}