#abc244e. E - King Bombee

E - King Bombee

Score : 500500 points

问题陈述

你得到一个包含 NN 个顶点和 MM 条边的简单无向图。顶点编号从 11NN,边编号从 11MM。第 ii 条边连接顶点 UiU_i 和顶点 ViV_i

给定整数 K,S,TK, S, TXX,满足以下条件的序列 A=(A0,A1,,AK)A = (A_0, A_1, \dots, A_K) 有多少种?

  • AiA_i 是一个介于 11NN(包括两端点)之间的整数。
  • A0=SA_0 = S
  • AK=TA_K = T
  • 存在一条直接连接顶点 AiA_i 和顶点 Ai+1A_{i+1} 的边。
  • 整数 X (XS,XT)X\ (X≠S,X≠T) 在序列 AA 中出现偶数次(可能为零)。

由于答案可能会非常大,求解答案对 998244353998244353 取模的结果。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

You are given a simple undirected graph with NN vertices and MM edges. The vertices are numbered from 11 through NN, and the edges are numbered from 11 through MM. Edge ii connects Vertex UiU_i and Vertex ViV_i.

You are given integers K,S,TK, S, T, and XX. How many sequences A=(A0,A1,,AK)A = (A_0, A_1, \dots, A_K) are there satisfying the following conditions?

  • AiA_i is an integer between 11 and NN (inclusive).
  • A0=SA_0 = S
  • AK=TA_K = T
  • There is an edge that directly connects Vertex AiA_i and Vertex Ai+1A_{i+1}.
  • Integer X (XS,XT)X\ (X≠S,X≠T) appears even number of times (possibly zero) in sequence AA.

Since the answer can be very large, find the answer modulo 998244353998244353.

Constraints

  • All values in input are integers.
  • 2N20002≤N≤2000
  • 1M20001≤M≤2000
  • 1K20001≤K≤2000
  • 1S,T,XN1≤S,T,X≤N
  • XSX≠S
  • XTX≠T
  • 1Ui<ViN1≤U_i<V_i≤N
  • If iji ≠ j, then (Ui,Vi)(Uj,Vj)(U_i, V_i) ≠ (U_j, V_j).

Input

Input is given from Standard Input in the following format:

NN MM KK SS TT XX

U1U_1 V1V_1

U2U_2 V2V_2

\vdots

UMU_M VMV_M

Output

Print the answer modulo 998244353998244353.

Sample Input 1

4 4 4 1 3 2
1 2
2 3
3 4
1 4

Sample Output 1

4

The following 44 sequences satisfy the conditions:

  • (1,2,1,2,3)(1, 2, 1, 2, 3)
  • (1,2,3,2,3)(1, 2, 3, 2, 3)
  • (1,4,1,4,3)(1, 4, 1, 4, 3)
  • (1,4,3,4,3)(1, 4, 3, 4, 3)

On the other hand, (1,2,3,4,3)(1, 2, 3, 4, 3) and (1,4,1,2,3)(1, 4, 1, 2, 3) do not, since there are odd number of occurrences of 22.

Sample Input 2

6 5 10 1 2 3
2 3
2 4
4 6
3 6
1 5

Sample Output 2

0

The graph is not necessarily connected.

Sample Input 3

10 15 20 4 4 6
2 6
2 7
5 7
4 5
2 4
3 7
1 7
1 4
2 9
5 10
1 3
7 8
7 9
1 6
1 2

Sample Output 3

952504739

Find the answer modulo 998244353998244353.

update @ 2024/3/10 10:29:36