This problem is in Contest(s) below:
Contest 1240:Kmp,扩展Kmp
Contest 1296:字符串入门
Contest 1139:矩阵乘法,Kmp,扩展Kmp