Under construction

Still being built. Things may change

Interesting Words

Time limit3sMemory limit2048 MB

Summary
Count the ordered sequences of given words whose concatenation is a palindrome of exact length L, modulo 1e9+7.
Level

Hard8 of 10

Topics
Dynamic programming, String matching, Hash map
Solved
No attempts yet

Problem

Ene loves palindromes.

Ene has a list of interesting words. She wants to select some interesting words and concatenate them to form a palindrome of length exactly LL. Each interesting word can be chosen multiple times or not chosen at all.

Ene wants to know the number of ways to do this. Two ways are considered different when the sequences of the concatenated interesting words in them are different. Multiple different ways may result in the same palindrome. Print the result modulo 109+710^9 + 7, since the answer may be very large.

Input

The first line contains two positive integers NN and LL, the number of interesting words and the length of the palindrome to be formed (1≤N≤3331 \le N \le 333, 1≤L≤10001 \le L \le 1000).

Each of the following NN lines contains an interesting word sis_i (1≤∣si∣≤L1 \le |s_i| \le L, ∑i=1N∣si∣≤600\sum_{i=1}^N |s_i| \le 600). The words contain only lowercase English letters and are pairwise distinct.

Output

Print a single integer: the number of ways to form a palindrome, modulo 109+710^9 + 7.

Hint

In the first sample, the five different ways are: stack cats; evil olive; eel eve lee; lee eve eel; eve eve eve.

Examples3

  1. Example 1

    Input
    7 9
    cats
    eel
    eve
    evil
    lee
    olive
    stack
    
    Expected output
    5
    
  2. Example 2

    Input
    2 2
    a
    aa
    
    Expected output
    2
    
  3. Example 3

    Input
    6 12
    aa
    aab
    no
    on
    pets
    step
    
    Expected output
    43