s=input()

s=s.replace(","," ")

s=s.replace("."," ")

for w in s.split():

  if 3<=len(w)<=6:print(w, end=' ')

print()
s=input().replace(","," ").replace("."," ").split()

s=" ".join([w for w in s if 2<len(w)<7])

print(s)
s = input()
s = s.replace(",", " ")
s = s.replace(".", " ")
for w in s.split():
    if 3 <= len(w) <= 6:
        print(w, end=" ")
print()

s = input().replace(",", " ").replace(".", " ").split()
s = " ".join([w for w in s if 2 < len(w) < 7])
print(s)

-s = input() -s = s.replace(",", " ") -s = s.replace(".", " ") -for w in s.split(): -    if 3 <= len(w) <= 6: -        print(w, end=" ") -print() +s = input().replace(",", " ").replace(".", " ").split() +s = " ".join([w for w in s if 2 < len(w) < 7]) +print(s)