时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 64 M,其他语言128 M
64bit IO Format: %lld
题目描述
Misaka Mikoto has a pattern string

. Let

be the length of

,

be the

-th character of

, and
![s[l\sim r]](https://www.nowcoder.com/equation?tex=s%5Bl%5Csim%20r%5D)
be the substring from the

-th character to the

-th character, that is,

.
In this problem, all characters are represented by an integer.
You need to perform

operations. There are two types of operations:
-
: change
to
.
-
: given a text string
, find the number of times
occurs as a substring in
and the longest border of
.
The longest border of 
means the largest number
)
that
![s[1\sim r]](https://www.nowcoder.com/equation?tex=s%5B1%5Csim%20r%5D)
is the same as
![s[(|s|-r+1)\sim|s|]](https://www.nowcoder.com/equation?tex=s%5B(%7Cs%7C-r%2B1)%5Csim%7Cs%7C%5D)
. If such

doesn't exist, let the
longest border of
be
.
Let's call the operation
"query".
Given two integers
, let
be the answer to the first and the second question of the
-th query, you only need to output
.
For some reason, the operations are encrypted. Let
be the value of
of the last query (if there aren't any queries before, let
be
). For operation
, you are given two integers
, which means
and
. For operation
, you are given an integer
and
integers
, which means
and
.
输入描述:
The first line contains four integers

.
The second line contains

integers, which represent the string

.
The

-th line of the following

lines contains the

-th operation:

or

.
输出描述:
One integer that represents the answer.
示例1
输入
复制
3 3 10 1000000007
1 2 1
2 5 1 2 1 2 1
1 3 3
2 4 3 3 3 3
备注:
For all test cases,

.

, where

represents the sum of

of all queries.

.

.