let define string x opening tag x small letter latin alphabet each opening tag match closing tag type x x letterTegs nest case open closing tag pair locate inside pairlet define notion XMLtext string XMLtext s XMLtext sasa XMLtext small latin letter s1 s2 XMLtexts s1s2 XMLtext you give XMLtext guarantee text valid task print follow form tag opening closing locate single line print tag 2h space h level tag nestedness