• + 0 comments

    import re

    def replace_operators(text): text = re.sub(r'(?<=\s)||(?=\s)', 'or', text) text = re.sub(r'(?<=\s)&&(?=\s)', 'and', text) return text

    N = int(input()) text = "\n".join(input() for _ in range(N)) result = replace_operators(text) print(result)