F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

AC/DC

Time Limit: 16000/8000 MS (Java/Others)    Memory Limit: 524288/262144 K (Java/Others)
Total Submission(s): 375    Accepted Submission(s): 92


Problem Description
J likes playing electric guitar, especially the famous guitar model - Gibson SG Standard. He always composes music with his Gibson SG Standard.

A tune he composes is made up of several notes. Formally, a $\bf{tune}$ can be regarded as a string consisting of only lower-case letters. Different letters stands for different notes. A substring of a tune is called $\bf{phrase}$.

At the beginning, J has a tune of length $n$. To create new music, J has three operations:

- $\mathtt{1\ c}$ : Insert a note $c$ at the end of the current tune.
- $\mathtt{2}$ : Delete the note at the beginning of the current tune.
- $\mathtt{3\ t}$ : Query the number of the phrase $t$ appears in the current tune.

Now, J is busy with his new album and invites you to write music together. Can you help him with it?
 

Input
The first line contains a single integer $T\ (1 \leq T \leq 5)$, the number of test cases. For each test case:

The first line contains a string $S$ of length $n$ $(1\le n \le 10^5)$ indicating the initial tune.

The next line contains one integer $m$ $(1\le m\le 10^5)$ indicating the number of operations.

For the following $m$ lines, the $i$-th line contains an operation like $\mathtt{1\ c}$, $\mathtt{2}$ or $\mathtt{3\ t}'$.

Let's define the last answer as $lastans$. At the beginning, $lastans = 0$.

- For $\mathtt{1\ c'}$, the real operation is $c = ((c'- 'a') \oplus lastans)\bmod 26 + 'a'$.
- For $\mathtt{3\ t'}$, the real operation is for every $1\le i\le |t|,\ t_i = ((t'_i-'a') \oplus lastans)\bmod 26 + 'a'$.

It's guaranteed that $c$ is a lower-case letter. $t$ is a string consisting only of lower-case letters. The sum of the lengths of $t$ of all test cases will not exceed $5 \times 10^6$.

Note that string $S$ may be deleted to an empty string. But it's guaranteed that there will be no operations of type 2 at this time.
 

Output
For each query $\mathtt{3\ t}$, print a single integer in a single line indicating the answer.
 

Sample Input
1 abcbaba 5 3 ab 3 c 1 a 2 3 da
 

Sample Output
2 3 1
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 20:58:49, Gzip enabled