| t | import sys | t | import sys |
| data = sys.stdin.buffer.read() | | data = sys.stdin.buffer.read() |
| parts = data.split(b'\x00') | | parts = data.split(b'\x00') |
| if parts: | | if parts: |
| text_bytes = parts[0] | | text_bytes = parts[0] |
| fragments = parts[1:] | | fragments = parts[1:] |
| if fragments and len(fragments[-1]) == 0: | | if fragments and len(fragments[-1]) == 0: |
| fragments.pop() | | fragments.pop() |
| try: | | try: |
| main_text = text_bytes.decode('utf-8') | | main_text = text_bytes.decode('utf-8') |
| except UnicodeDecodeError: | | except UnicodeDecodeError: |
| main_text = '' | | main_text = '' |
| encodings = ['cp866', 'cp1251', 'koi8-r', 'iso-8859-5'] | | encodings = ['cp866', 'cp1251', 'koi8-r', 'iso-8859-5'] |
| for frag in fragments: | | for frag in fragments: |
| found = False | | found = False |
| for enc in encodings: | | for enc in encodings: |
| try: | | try: |
| decoded = frag.decode(enc) | | decoded = frag.decode(enc) |
| if decoded in main_text: | | if decoded in main_text: |
| found = True | | found = True |
| break | | break |
| except UnicodeDecodeError: | | except UnicodeDecodeError: |
| continue | | continue |
| print('Yes' if found else 'No') | | print('Yes' if found else 'No') |