Longest Common Substring
시간 제한5초메모리 제한2048 MB
길이가 n과 m인 이진 문자열 쌍 중에서 최장 공통 부분 문자열이 길이 3 이하의 주어진 w인 쌍의 개수를 센다.
문제
Lisa wrote a program to solve the Longest Common Substring problem. She then used the program to find, for some two strings and consisting of characters '0' and '1', the longest string that is a substring of both and . If there were multiple such longest strings, she found an arbitrary one.
Notably, the length of Lisa found was very small --- at most 3.
Lisa remembers (the length of ), (the length of ), and , but she doesn't remember strings and themselves. Now she wonders how many pairs of strings and exist such that they have lengths and , respectively, consist of characters '0' and '1', and have as one of their longest common substrings.
Help Lisa and find this number of pairs modulo . Note that if and , pairs and are considered distinct.
입력
The first line contains three integers , , and , denoting the lengths of the strings , , and (; ).
The second line contains the string of length consisting of characters '0' and '1'.
출력
Print the number of pairs of strings that have as one of their longest common substrings, modulo .
힌트
Note that a string is a substring of a string if can be obtained from by deleting zero or more characters from the beginning and zero or more characters from the end.
In the first test, all pairs of strings satisfying the conditions are ("01", "10"), ("01", "11"), ("10", "01"), ("10", "11"), ("11", "01"), and ("11", "10").