May God bless you..!!

I am stucked in one question of March long contest

and i found that it is much similar in approach as this question
ABCSTR Problem - CodeChef.
I read the editorial also of the ABCSTR and i followed it , but still i got the tle :frowning: :frowning: … plzz help me to solve the second question (ABCSTR) …plzzzzz!!! …
Here is the link of editorial of ABCSTR question…
ABCSTR - Editorial - editorial - CodeChef Discuss