DNA Evolution

题意翻译

DNA链由核苷酸组成。有四种类型的核苷酸:“A”,“T”,“G”,“C”。 DNA链是核苷酸序列。科学家决定追踪一种稀有物种的进化,它最初的DNA链为s。 物种的进化被描述为DNA的一系列变化。每个变化都是某些核苷酸的变化,例如,DNA链“AAGC”中可能发生以下变化:第二个核苷酸可以变为“T”,然后变成“ATGC”。 科学家们知道DNA链的某些片段会受到某些未知感染的影响。这些感染可以被表示为核苷酸序列。科学家们对引起变化的感染十分感兴趣。因此,他们有时想知道某些感染对某些DNA片段的影响的价值。价值是这样计算的: 用字符串e代表表示感染的核苷酸序列,科学家们对DNA序列从l到r(包括端点)的片段感兴趣。 把字符串eee……的前缀(即字符串e重复许多次组成的字符串)写在字符串s从l到r(包括端点)的片段下边。 感染对DNA片段的价值是感染与DNA片段在l到r区间内,相同位置相同的核苷酸的数量。 作为开发者,Innokenty也对生物信息学感兴趣,因此科学家们向他求助。 Innokenty正在忙着准备VK杯,所以他决定将问题交给参赛者们。来帮帮科学家们吧!

题目描述

Everyone knows that DNA strands consist of nucleotides. There are four types of nucleotides: "A", "T", "G", "C". A DNA strand is a sequence of nucleotides. Scientists decided to track evolution of a rare species, which DNA strand was string $ s $ initially. Evolution of the species is described as a sequence of changes in the DNA. Every change is a change of some nucleotide, for example, the following change can happen in DNA strand "AAGC": the second nucleotide can change to "T" so that the resulting DNA strand is "ATGC". Scientists know that some segments of the DNA strand can be affected by some unknown infections. They can represent an infection as a sequence of nucleotides. Scientists are interested if there are any changes caused by some infections. Thus they sometimes want to know the value of impact of some infection to some segment of the DNA. This value is computed as follows: - Let the infection be represented as a string $ e $ , and let scientists be interested in DNA strand segment starting from position $ l $ to position $ r $ , inclusive. - Prefix of the string $ eee... $ (i.e. the string that consists of infinitely many repeats of string $ e $ ) is written under the string $ s $ from position $ l $ to position $ r $ , inclusive. - The value of impact is the number of positions where letter of string $ s $ coincided with the letter written under it. Being a developer, Innokenty is interested in bioinformatics also, so the scientists asked him for help. Innokenty is busy preparing VK Cup, so he decided to delegate the problem to the competitors. Help the scientists!

输入输出格式

输入格式


The first line contains the string $ s $ ( $ 1<=|s|<=10^{5} $ ) that describes the initial DNA strand. It consists only of capital English letters "A", "T", "G" and "C". The next line contains single integer $ q $ ( $ 1<=q<=10^{5} $ ) — the number of events. After that, $ q $ lines follow, each describes one event. Each of the lines has one of two formats: - 1 x c, where $ x $ is an integer ( $ 1<=x<=|s| $ ), and $ c $ is a letter "A", "T", "G" or "C", which means that there is a change in the DNA: the nucleotide at position $ x $ is now $ c $ . - 2 l r e, where $ l $ , $ r $ are integers ( $ 1<=l<=r<=|s| $ ), and $ e $ is a string of letters "A", "T", "G" and "C" ( $ 1<=|e|<=10 $ ), which means that scientists are interested in the value of impact of infection $ e $ to the segment of DNA strand from position $ l $ to position $ r $ , inclusive.

输出格式


For each scientists' query (second type query) print a single integer in a new line — the value of impact of the infection on the DNA.

输入输出样例

输入样例 #1

ATGCATGC
4
2 1 8 ATGC
2 2 6 TTT
1 4 T
2 2 6 TA

输出样例 #1

8
2
4

输入样例 #2

GAGTTGTTAA
6
2 3 4 TATGGTG
1 1 T
1 6 G
2 5 9 AGTAATA
1 10 G
2 2 6 TTGT

输出样例 #2

0
3
1

说明

Consider the first example. In the first query of second type all characters coincide, so the answer is $ 8 $ . In the second query we compare string "TTTTT..." and the substring "TGCAT". There are two matches. In the third query, after the DNA change, we compare string "TATAT..."' with substring "TGTAT". There are $ 4 $ matches.