| SVU-HIAST CPC 2025 |
|---|
| Finished |
While Obada was tidying up his house for the party, he found a word written by lowercase letters balloons. Obada loves palindromes, so he wants to make the word a palindrome. Obada can only reshuffle letters of a subarray $$$[L,R]$$$ of a string. But every now and then, Obada's brother changes a letter in the string. Obada found this an interesting problem and wants you to solve it.
Obada will give you a string $$$s$$$ of $$$n$$$ lowercase letters and $$$q$$$ queries of the following types:
A palindrome is a string that reads the same backward as forward; for example, strings "z", "aaa", "aba", "abccba" are palindromes, but strings "ammar", "bassam", "ab" are not.
Can you solve this problem?
The first line contains a single integer $$$tc \: (1 \leq tc \leq 100)$$$ — the number of testcases.
The first line of each testcase consists of two integers $$$n,q \: (1 \leq n,q \leq 10^5)$$$— the length of $$$s$$$ and the number of queries.
The second line of each test case contains the string $$$s$$$ of length $$$n$$$ containing only lowercase latin letters.
The next $$$q$$$ lines describe the queries, each line is like one of the following:
It is guaranteed that there will be at least one query of the second type in each testcase, and the sum of each of $$$n$$$ and $$$q$$$ over all testcases doesn't exceed $$$10^5$$$.
For each query of the second type, print the number of different palindromic strings he could obtain from $$$s$$$ by reshuffling the letters in the subarray $$$[L,R]$$$, modulo $$$10^9+7$$$.
410 3abcdecedba2 6 81 10 b2 6 810 5abcdeabcde2 1 102 1 51 1 e1 2 d2 3 83 4aab2 1 22 2 31 1 b2 2 35 3caabc2 2 41 5 a2 2 4
1 0 120 1 0 0 1 1 1 0
| Name |
|---|


