It's from Winter school 2013 http://2013.ws.kh.ua/lang/en/ http://2013.ws.kh.ua/media/sbornik/Sbornik2013.pdf
Described that it should be solved with online Ukkonen's algorithm because it works by adding one character to the tree and know the length of not unique suffix, which gives answer for second query type.
But I'm still not able to get 100%.