#ABC470F. 古戈尔交换 / Googol Swaps
古戈尔交换 / Googol Swaps
Problem Statement
You are given a string of length consisting of lowercase English letters.
Find the number, modulo , of strings that can become after performing the following operation exactly times.
- Choose an integer between and , inclusive, and swap the -th and -th characters of .
Constraints
- and are integers.
- is a string of length consisting of lowercase English letters.
- and are integers.
- are pairwise distinct.
Input
The input is given from Standard Input in the following format:
$N$ $M$
$S$
$A_1$ $B_1$
$\vdots$
$A_M$ $B_M$
Output
Output the answer.
5 3
miria
1 3
2 5
4 5
6
The following six strings are possible as the final :
mariimiraimiriaramiirimairimia
6 6
yiwayi
1 2
1 3
2 3
4 5
4 6
5 6
18
29 25
hexakosioihexekontahexaphobia
1 2
1 4
1 6
1 8
1 15
1 16
2 3
3 4
4 20
5 6
5 8
8 22
8 23
9 15
9 17
11 21
12 20
13 19
14 29
15 28
16 17
18 19
18 21
19 20
20 21
346192062
- Source: AtCoder ABC 470 F
相关
在下列比赛中: