Niuniu is practicing typing. Given n words, Niuniu want to input one of these.He wants to input as few characters as possible, to make at least one of the n words appears in the text. Given an operation sequence, Niuniu want to know the answer after every operation. An operation might input a characteror delete the last character.
Niuniu is practicing typing. Given n words, Niuniu want to input one of these. He wants to input (at the end) as few characters (without backspace) as possible, to make at least one of the n words appears (as a suffix) in the text. Given an operation sequence, Niuniu want to know the answer after every operation. An operation might input a character or delete the last character.
(图片来源网络,侵删)