Doubt in one codeforce question

Hii everyone…
I am trying to solve this question…

https://codeforces.com/contest/1379/problem/A

This is my solution–

I am not able to find the error… means don’t know where the test case is failing… If anyone could help…

Hey @ashishnnnnn
One test case where your logic will fail:
1
15
abaca?acaba?aba
Here answer should be
YES
abacaxacabacaba

Follow the tutorial for correct implementation :https://codeforces.com/blog/entry/80216

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.