<reponame>15ers/Solve_Naively<gh_stars>1-10
import re

stream = input()
p = re.compile("<?[^<>]+>?")
ans = ""
for elem in p.findall(stream):
    if elem[0] == "<":
        ans += elem
    else:
        for e in elem.split():
            ans += e[::-1] + " "
        ans = ans.rstrip()
print(ans)
import re

stream = input()
p = re.compile("<?[^<>]+>?")
ans = ""
for elem in p.findall(stream):
    if elem[0] == "<":
        ans += elem
    else:
        for e in elem.split():
            ans += e[::-1] + " "
        ans = ans.rstrip()
print(ans)