F. 古戈尔交换 / Googol Swaps

    传统题 2000ms 256MiB

古戈尔交换 / Googol Swaps

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Problem Statement

You are given a string SS of length NN consisting of lowercase English letters.
Find the number, modulo 998244353998244353, of strings that SS can become after performing the following operation exactly 1010010^{100} times.

  • Choose an integer ii between 11 and MM, inclusive, and swap the AiA_i-th and BiB_i-th characters of SS.

Constraints

  • NN and MM are integers.
  • 2N2×1052 \leq N \leq 2 \times 10^5
  • 1M2×1051 \leq M \leq 2 \times 10^5
  • SS is a string of length NN consisting of lowercase English letters.
  • AiA_i and BiB_i are integers.
  • 1Ai<BiN1 \leq A_i < B_i \leq N
  • (A1,B1),,(AM,BM)(A_1, B_1), \dots, (A_M, B_M) 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 SS:

  • marii
  • mirai
  • miria
  • ramii
  • rimai
  • rimia
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

ABC470 赛后模拟赛 ✅

未参加
状态
已结束
规则
IOI
题目
7
开始于
2026-8-10 17:00
结束于
2026-8-17 17:00
持续时间
168 小时
主持人
参赛人数
82