Three Religions

题意翻译

给定长度为 $n$ 的母串和三个子串 $s_1,s_2,s_3$。初始时子串均为空。有 $q$ 次询问。你需要支持两种操作:向某个子串末尾添加一个字母,或者删去某个子串末尾的字母。在每次操作后,你需要回答,是否能从母串中分离出三个不相交的子序列(不改变字符原有顺序),满足这三个子序列恰好是 $s_1,s_2,s_3$。 在任意时刻,$s_1,s_2,s_3$ 的长度均不会超过 $250$。 $1 \le n \le 10^5$ , $1\le q \le 10^3$

题目描述

During the archaeological research in the Middle East you found the traces of three ancient religions: First religion, Second religion and Third religion. You compiled the information on the evolution of each of these beliefs, and you now wonder if the followers of each religion could coexist in peace. The Word of Universe is a long word containing the lowercase English characters only. At each moment of time, each of the religion beliefs could be described by a word consisting of lowercase English characters. The three religions can coexist in peace if their descriptions form disjoint subsequences of the Word of Universe. More formally, one can paint some of the characters of the Word of Universe in three colors: $ 1 $ , $ 2 $ , $ 3 $ , so that each character is painted in at most one color, and the description of the $ i $ -th religion can be constructed from the Word of Universe by removing all characters that aren't painted in color $ i $ . The religions however evolve. In the beginning, each religion description is empty. Every once in a while, either a character is appended to the end of the description of a single religion, or the last character is dropped from the description. After each change, determine if the religions could coexist in peace.

输入输出格式

输入格式


The first line of the input contains two integers $ n, q $ ( $ 1 \leq n \leq 100\,000 $ , $ 1 \leq q \leq 1000 $ ) — the length of the Word of Universe and the number of religion evolutions, respectively. The following line contains the Word of Universe — a string of length $ n $ consisting of lowercase English characters. Each of the following line describes a single evolution and is in one of the following formats: - + $ i $ $ c $ ( $ i \in \{1, 2, 3\} $ , $ c \in \{\mathtt{a}, \mathtt{b}, \dots, \mathtt{z}\} $ : append the character $ c $ to the end of $ i $ -th religion description. - - $ i $ ( $ i \in \{1, 2, 3\} $ ) – remove the last character from the $ i $ -th religion description. You can assume that the pattern is non-empty. You can assume that no religion will have description longer than $ 250 $ characters.

输出格式


Write $ q $ lines. The $ i $ -th of them should be YES if the religions could coexist in peace after the $ i $ -th evolution, or NO otherwise. You can print each character in any case (either upper or lower).

输入输出样例

输入样例 #1

6 8
abdabc
+ 1 a
+ 1 d
+ 2 b
+ 2 c
+ 3 a
+ 3 b
+ 1 c
- 2

输出样例 #1

YES
YES
YES
YES
YES
YES
NO
YES

输入样例 #2

6 8
abbaab
+ 1 a
+ 2 a
+ 3 a
+ 1 b
+ 2 b
+ 3 b
- 1
+ 2 z

输出样例 #2

YES
YES
YES
YES
YES
NO
YES
NO

说明

In the first example, after the 6th evolution the religion descriptions are: ad, bc, and ab. The following figure shows how these descriptions form three disjoint subsequences of the Word of Universe: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1149B/d2161037f06cd41962d7459e510bbcc1eef61be4.png)