This page is still under construction.

Parts of this page are still being built. What you see may change.

Measuring WAC-ness

Time limit1sMemory limit512 MB

Summary
Count subsequences equal to WAC in a base string repeated K times, modulo 998244353.
Level

Medium7 of 10

Topics
Combinatorics, Math, String, Dynamic programming
Solved
No attempts yet

Problem

Consider a string of length NN. Let string SS be that string repeated KK times. You are interested in how wack the string is, so your task is to find the WAC-ness of this string.

The WAC-ness of a string is the number of times "WAC" appears as a subsequence of that string.

A subsequence of a string is a string that can be derived from the given string by deleting zero or more characters without changing the order of the remaining characters. Two subsequences are different if at least one of the remaining indices is different. For example, in the string "AABC", the subsequence formed by indices 11, 33, and 44 is distinct from the subsequence formed by indices 22, 33, and 44.

As the answer can be very large, output the answer modulo 998 244 353998\,244\,353.

Input

The first line contains two integers, NN and KK (1≤N≤200 0001 \le N \le 200\,000, 1≤K≤200 0001 \le K \le 200\,000), the length of the original string and the number of times that string is repeated to form SS. The second and final line contains the original string of NN characters, consisting of uppercase letters of the English alphabet.

Output

Output the WAC-ness of the string SS modulo 998 244 353998\,244\,353.

Examples2

  1. Example 1

    Input
    5 1
    WABCA
    
    Expected output
    1
    
  2. Example 2

    Input
    5 2
    WABCA
    
    Expected output
    5