Can you please provide its correct solution code?

I did not understand how to build trees with string given as inputs…I even checked the editorial code…even that code is giving WA…can you please provide its correct solution code?