import re import sys def replace_third_word(match): if match.group(2): replacement = 'x' * len(match.group(2)) return f"{match.group(1)}{replacement}{match.group(3)}" else: return match.group(0) def replace_third_word_in_line(line): pattern = re.compile(r'((?:\b\w+\b\s+){2})(\b\w+\b)(.*)') replaced_line = pattern.sub(replace_third_word, line) return replaced_line for line in sys.stdin: output_line = replace_third_word_in_line(line.strip()) sys.stdout.write(output_line + '\n')