Codeforces 696D Legen... AC自动机 + 矩阵快速幂

NoSuchKey