Splits

시간 제한5초메모리 제한2048 MB

문제

For a permutation $p = p[0] p[1] p[2] \dots p[n − 1]$ of the numbers $1, 2, 3,\dots,n$ we define a split as a permutation $q$ which can be obtained by the following process:

  1. Select two sets of numbers $A = \{ i_1 ,i_2 , \dots , i_k \}$ and $B = \{ j_1 , j_2 ,\dots , j_l \}$ such that $A ∩ B = ∅$, $A ∪ B = \{ 0, 1, 2, \dots ,n − 1 \}$, $i_1 < i_2 < \dots < i_k$ and $j_1 < j_2 < \dots < j_l$.
  2. The permutation $q$ will be $q = p[i_1 ]p[i_2 ]\dots p[i_k ]p[j_1 ]p[j_2 ]\dots p[j_l ]$

Moreover, we define $S(p)$ to be the set of all splits of a permutation $p$.

You are given a number $n$ and a set $T$ of $m$ permutations of length $n$. Count how many permutations $p$ of length $n$ exist such that $T ⊆ S(p)$. Since this number can be large, find it modulo $998\, 244\, 353$.

제한

  • $1 ≤ n ≤ 300$
  • $1 ≤ m ≤ 300$