import re import sys def re_find_hamlet(input): for _, l in enumerate(input, start=1): if re.search(r'\bHamlet\b', l): print(l.strip()) re_find_hamlet(sys.stdin)