7 + apple + app + application ? app + banana ? ban ? ap
For this input, the required output is 3 1 3.
3 1 3
5 ? hello + hello ? hello ? hell ? helloworld
For this input, the required output is 0 1 1 0.
0 1 1 0
9 + a + ab + abc + abcd ? a ? ab ? abc ? abcd ? abcde
For this input, the required output is 4 3 2 1 0.
4 3 2 1 0
Given nnn operations on a Trie (prefix tree):
+ word
word
? prefix
prefix
For each query, output the answer on a separate line.