Under construction

Still being built. Things may change

Longest Common Substring

Time limit5sMemory limit2048 MB

Summary
Count the pairs of binary strings s (length n) and t (length m) that have w as one of their longest common substrings, modulo 998244353.
Level

Medium7 of 10

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

Statement

Lisa wrote a program to solve the Longest Common Substring problem. She then used the program to find, for some two strings ss and tt consisting of characters '0' and '1', the longest string ww that is a substring of both ss and tt. If there were multiple such longest strings, she found an arbitrary one.

The length of ww that Lisa found was very small. It is at most 3.

Lisa remembers nn (the length of ss), mm (the length of tt), and ww, but she does not remember the strings ss and tt themselves. Now she wonders how many pairs of strings ss and tt exist such that they have lengths nn and mm, respectively, consist of characters '0' and '1', and have ww as one of their longest common substrings.

Help Lisa and find this number of pairs modulo 998 244 353998\,244\,353. Note that if n=mn = m and s≠ts \ne t, pairs (s,t)(s, t) and (t,s)(t, s) are considered distinct.

Input

The first line contains three integers nn, mm, and kk, denoting the lengths of the strings ss, tt, and ww (1≤n,m≤1001 \le n, m \le 100; 1≤k≤min⁡(3,n,m)1 \le k \le \min(3, n, m)).

The second line contains the string ww of length kk consisting of characters '0' and '1'.

Output

Print the number of pairs of strings (s,t)(s, t) that have ww as one of their longest common substrings, modulo 998 244 353998\,244\,353.

Hint

Note that a string aa is a substring of a string bb if aa can be obtained from bb 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").

Examples4

  1. Example 1

    Input
    2 2 1
    1
    
    Expected output
    6
    
  2. Example 2

    Input
    3 4 2
    01
    
    Expected output
    28
    
  3. Example 3

    Input
    7 5 3
    110
    
    Expected output
    399
    
  4. Example 4

    Input
    23 42 3
    000
    
    Expected output
    174497840