#abc213h. H - Stroll

H - Stroll

Score : 600600 points

问题描述

高桥决定在自家周围闲逛。
在他的漫步过程中,他将在被称为 Point 1、Point 2、...、Point N 的 NN 个点之间漫游,其中 Point 1 是他的家。
MM 对由道路连接的点对;设 (ai,bi)(a_i, b_i) 表示第 ii 对这样的点对。在 Point aia_i 和 Point bib_i 之间有长度为 dd1dT1 \leq d \leq T)千米的道路,共有 pi,dp_{i, d} 条。

高桥想知道从他家出发并返回到他家的 TT 千米路线的数量。这里,一个 TT 千米路线定义如下:

  • 一个交替的点和道路序列 v0=1,e0,v1,,ek1,vk=1v_0 = 1, e_0, v_1, \dots, e_{k-1}, v_k = 1,满足 eie_i (0ik1)(0 \leq i \leq k-1) 连接 viv_ivi+1v_{i+1},且所有 eie_i 的总长度为 TT 千米。

请帮助高桥计算满足条件的路线数量,并将结果对 998244353998244353 取模。当两条路线作为序列时不同,则认为它们是不同的路线。

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

Problem Statement

Takahashi has decided to wander around his house.
During his walk, he will roam between NN points called Point 11, Point 22, \dots, Point NN, where Point 11 is his house.
There are MM pairs of points connected by roads; let (ai,bi)(a_i, b_i) be the ii-th of these pairs. There are pi,dp_{i, d} roads with a length of dd (1dT)(1 \leq d \leq T) kilometers connecting Point aia_i and Point bib_i.

Takahashi wants to know the number of TT kilometers courses that begin and end at his house. Here, a TT kilometers course is defined as follows.

  • An alternating sequence with points and roads v0=1,e0,v1,,ek1,vk=1v_0 = 1, e_0, v_1, \dots,e_{k-1}, v_k = 1 such that eie_i (0ik1)(0 \leq i \leq k-1) connects viv_i and vi+1v_{i+1}, and the total length of eie_i is TT kilometers.

Help Takahashi by finding the number of such courses modulo 998244353998244353. Two courses are considered different when they are different as sequences.

Constraints

  • 2N102 \leq N \leq 10
  • $1 \leq M \leq \min \left(10, \frac{N(N-1)}{2} \right)$
  • 1T4×1041 \leq T \leq 4 \times 10^4
  • 1ai<biN1 \leq a_i \lt b_i \leq N
  • (ai,bi)(aj,bj)(a_i, b_i) \neq (a_j, b_j) if iji \neq j.
  • 0pi,j<9982443530 \leq p_{i,j} \lt 998244353

Input

Input is given from Standard Input in the following format:

NN MM TT

a1a_1 b1b_1

p1,1p_{1,1} p1,2p_{1,2} \ldots p1,Tp_{1,T}

\vdots

aMa_M bMb_M

pM,1p_{M,1} pM,2p_{M,2} \ldots pM,Tp_{M,T}

Output

Print the number of desirable courses, modulo 998244353998244353.

Sample Input 1

3 2 2
1 2
1 0
1 3
2 0

Sample Output 1

5

Around his house, there are:

  • one 11-kilometer road connecting Point 11 and Point 22, and
  • two 11-kilometer roads connecting Point 11 and Point 33.

We have the following five desirable courses:

  • 1×1=11 \times 1 = 1 course that goes Point 11 \to Point 22 \to Point 11, and
  • 2×2=42 \times 2 = 4 courses that goes Point 11 \to Point 33 \to Point 11.

Sample Input 2

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

Sample Output 2

130

Around his house, there are:

  • three 11-kilometer roads connecting Point 11 and Point 22,
  • one 22-kilometer road connecting Point 11 and Point 33, and
  • two 11-kilometer roads connecting Point 22 and Point 33.

The desirable courses can be classified into the following categories, according to the points visited:

  • Point 11 \to Point 22 \to Point 11 \to Point 22 \to Point 11,
  • Point 11 \to Point 22 \to Point 33 \to Point 11,
  • Point 11 \to Point 22 \to Point 33 \to Point 22 \to Point 11,
  • Point 11 \to Point 33 \to Point 11, and
  • Point 11 \to Point 33 \to Point 22 \to Point 11.

We have 8181, 66, 3636, 11, and 66 course(s) of these categories, respectively.

Sample Input 3

2 1 5
1 2
31415 92653 58979 32384 62643

Sample Output 3

844557977

update @ 2024/3/10 09:30:44

}