actGenshinImp
시간 제한5초메모리 제한2048 MB
서로 다른 13개 칸으로 이루어진 단순 경로 중 글자가 genshinimpact의 순환 이동과 일치하는 경로의 개수를 998244353으로 나눈 나머지를 구한다.
문제
In the recent few years, this game has been so popular worldwide, it has even become a meme in the competitive programming community. Why would it be a bad idea to set problems about it?
You are given a grid of lowercase latin alphabets. A simple path on this grid is defined as a sequence of distinct cells , such that and are adjacent either vertically or horizontally. Also, for some simple path of cells, let be the string of length such that is the letter written on the cell of the grid .
Please find the number of simple paths of cells, such that is a cyclic shift of "genshinimpact". As the answer may be very large, you are only required to find the value modulo .
입력
The first line contains two integers and --- the number of rows and the number of columns of . ()
Each of the following lines contains a string of length consisting of lowercase latin letters. The -th of them is the -th row of the grid .
출력
Output the answer modulo on one line.
힌트
The grid in the sample input contains simple paths satisfying the condition. The simple paths are as follows.
