This problem is in Contest(s) below:
Contest 1503:各种自动机
Contest 1504:YC_2021_4月