Comments

Ya i misunderstood suffix for prefix. Thanks for replying back. After understanding the question ,my solution was AC for all test case. http://codeforces.me/contest/820/submission/28138209.Link to my solution

The queried string will be:ffff fghij fffffffffff fghi //My example is wrong ,i misunderstood suffix for prefix The output:5

a>abc b>d a>def b>f a>def Resultant string>abcddeffdef String from L to R>ddeffde So the answer :-3