CF1574F.Occurrences

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A subarray of array aa from index ll to the index rr is the array [al,al+1,,ar][a_l, a_{l+1}, \dots, a_{r}] . The number of occurrences of the array bb in the array aa is the number of subarrays of aa such that they are equal to bb .

You are given nn arrays A1,A2,,AnA_1, A_2, \dots, A_n ; the elements of these arrays are integers from 11 to kk . You have to build an array aa consisting of mm integers from 11 to kk in such a way that, for every given subarray AiA_i , the number of occurrences of AiA_i in the array aa is not less than the number of occurrences of each non-empty subarray of AiA_i in aa . Note that if AiA_i doesn't occur in aa , and no subarray of AiA_i occurs in aa , this condition is still met for AiA_i .

Your task is to calculate the number of different arrays aa you can build, and print it modulo 998244353998244353 .

输入格式

The first line contains three integers nn , mm and kk ( 1n,m,k31051 \le n, m, k \le 3 \cdot 10^5 ) — the number of the given arrays, the desired length of the array aa , and the upper bound on the values in the arrays.

Then nn lines follow. The ii -th line represents the array AiA_i . The first integer in the ii -th line is cic_i ( 1cim1 \le c_i \le m ) — the number of elements in AiA_i ; then, cic_i integers from 11 to kk follow — the elements of the array AiA_i .

Additional constraint on the input: i=1nci3105\sum\limits_{i=1}^n c_i \le 3 \cdot 10^5 ; i. e., the number of elements in the given arrays in total does not exceed 31053 \cdot 10^5 .

输出格式

Print one integer — the number of different arrays aa you can build, taken modulo 998244353998244353 .

输入输出样例

  • 输入#1

    2 4 3
    2 1 2
    1 3

    输出#1

    5
  • 输入#2

    2 4 3
    2 1 2
    3 3 2 1

    输出#2

    0
  • 输入#3

    1 42 1337
    2 13 31

    输出#3

    721234447
首页