Lizi studied Trie in Data Structure class. He learned that Trie is a rooted tree to store some strings. There is a character on each edge of a Trie. In this problem, valid characters are only lowercase Latin letters.
There is a Trie T. At the beginning, the Trie only has a root, which is labeled 0.
Now you also have a string S ( At the beginning, it's a empty string.)
We use $P_i$ to denote the string concatenated with characters on the path from the root to node labeled i.
We use $Q_i$ to denote the prefix of the string S, which length is i.
Now give you m operations of the following forms.
ADD u v c
Insert a node labeled v. The node's father is u, and the character between the node and its father is c. Assume the label of the node is exactly the max label of the tree's node +1 .
ASK p1 p2 t
Ask whether there exists a string $Q_l$($0 \le p1\le l \le p2 \le Length(S)$ ), which is meanwhile a substring of $P_t$. Output 'yes' or 'no'.
INS p1 p2
Add a charcter c at the end of the string. Unluckly, we only know the character is between p1 and p2. That is to say, $'a'\le p1\le c\le p2\le 'z'$.