Interesting Words
시간 제한3초메모리 제한2048 MB
주어진 단어를 중복 사용해 이어 붙여 길이가 정확히 L인 회문을 만드는 방법의 수를 1e9+7로 나눈 나머지로 구한다.
문제
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 . 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. Note that multiple different ways may result in the same palindrome. Since the answer may be very large, you need to find the result modulo .
입력
The first line of the input contains two positive integers and representing the number of the interesting words and the length of the palindrome to be formed (, ).
Each of the following lines contains an interesting word (, ; the interesting words only contain lowercase English letters and are pairwise distinct).
출력
Output a line with a single integer: the number of ways to form a palindrome modulo .
힌트
In the first example, the five different ways are the following:
stack cats; evil olive; eel eve lee; lee eve eel; eve eve eve.