#P1910I. Inverse Problem
Inverse Problem
Description
Consider the following problem.
You are given a string , consisting of lowercase Latin letters, and an integer ( is not divisible by ). Each letter is one of the first letters of the alphabet.
You apply the following operation until the length of the string is less than : choose a contiguous substring of the string of length exactly , remove it from the string and glue the resulting parts together without changing the order.
Let the resulting string of length smaller than be . What is lexicographically smallest string that can obtained?
You are asked the inverse of this problem. Given two integers and ( is not divisible by ) and a string , consisting of () lowercase Latin letters, count the number of strings that produce as the lexicographically smallest solution.
Print that number modulo .
The first line contains three integers and (; ; ; is not divisible by ) — the length of string , the length of the substring that is being removed and the number of first letters from the alphabet.
The second line contains string , consisting of exactly () lowercase Latin letters. Each letter is one of the first letters of the alphabet.
Print a single integer — the number of strings that produce as the lexicographically smallest solution.
Input
The first line contains three integers and (; ; ; is not divisible by ) — the length of string , the length of the substring that is being removed and the number of first letters from the alphabet.
The second line contains string , consisting of exactly () lowercase Latin letters. Each letter is one of the first letters of the alphabet.
Output
Print a single integer — the number of strings that produce as the lexicographically smallest solution.
Note
The strings in the first example: "aaa", "aab", "aba", "abb", "baa", "bba".
The strings in the second example: "bcabc", "bcacc", "bcbbc", "bcbcc", "bccbc", "bcccc", "caabc", "cabbc", "cacbc", "cbabc", "cbbbc", "cbcbc", "ccabc", "ccbbc", "cccbc".