typewriter

AtCoder
IDabc246_f
Time2000ms
Memory256MB
Difficulty
We have a typewriter with $N$ rows. The keys in the $i$\-th row from the top can type the characters in a string $S_i$. Let us use this keyboard to enter a string, as follows. * First, choose an integer $1 \le k \le N$. * Then, start with an empty string and only use the keys in the $k$\-th row from the top to enter a string of length exactly $L$. How many strings of length $L$ can be entered in this way? Since the answer can be enormous, print it modulo $998244353$. ## Constraints * $N$ and $L$ are integers. * $1 \le N \le 18$ * $1 \le L \le 10^9$ * $S_i$ is a (not necessarily contiguous) non-empty subsequence of `abcdefghijklmnopqrstuvwxyz`. ## Input Input is given from Standard Input in the following format: $N$ $L$ $S_1$ $S_2$ $\dots$ $S_N$ [samples]
Samples
Input #1
2 2
ab
ac
Output #1
7

We can enter seven strings: `aa`, `ab`, `ac`, `ba`, `bb`, `ca`, `cc`.
Input #2
4 3
abcdefg
hijklmnop
qrstuv
wxyz
Output #2
1352
Input #3
5 1000000000
abc
acde
cefg
abcfh
dghi
Output #3
346462871

Be sure to print the answer modulo $998244353$.
API Response (JSON)
{
  "problem": {
    "name": "typewriter",
    "description": {
      "content": "We have a typewriter with $N$ rows. The keys in the $i$\\-th row from the top can type the characters in a string $S_i$. Let us use this keyboard to enter a string, as follows. *   First, choose an in",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc246_f"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "We have a typewriter with $N$ rows. The keys in the $i$\\-th row from the top can type the characters in a string $S_i$.\nLet us use this keyboard to enter a string, as follows.\n\n*   First, choose an in...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments