| Author: | mesenev | Time limit: | 2 sec | |
| Input file: | input.txt | Memory limit: | 512 Mb | |
| Output file: | output.txt |
Your consciousness is branching. The initial state of complete amnesia is version 0. In total, Q mental acts will take place during the investigation. Each act gives birth to a new version of your "self" (versions are numbered strictly from 1 to Q). Your consciousness is in a state of permanent psychosis, so you cannot predict the future: each next request is encrypted using the answer to the previous request that required output.
Mental acts are of three types:
Decryption mechanism (Online). Let last_ans be the answer to the last output query of the third type (initially last_ans = 0). Each string s or p in the input is encrypted with a cyclic shift: to decrypt a string, every character must be shifted backward through the alphabet by last_ans positions: cdecrypted = ((c − 'a' − last_ans) mod 26 + 26) mod 26 + 'a'. The base version number v is always given in the input in unencrypted form.
The first line of the input file contains a single integer Q — the number of mental acts.
The next Q lines describe the acts in chronological order. Each line starts with the act type type (1 ≤ type ≤ 3) and the base version number v (0 ≤ v < i, where i is the index of the current query, from 1 to Q). If type = 1 or type = 2, an encrypted string s follows. If type = 3, an encrypted string p follows.
The total length of all strings in the input does not exceed 106. All decrypted strings consist of lowercase Latin letters and are non-empty.
For each query of the third type, output a single integer — the answer. Output each answer on its own line.
1 ≤ Q ≤ 2 ⋅ 105
| No. | Input file (input.txt) |
Output file (output.txt) |
|---|---|---|
| 1 |
|
|