| f | import sys | f | import sys |
| n | data = sys.stdin.buffer.read() | n | raw_data = sys.stdin.buffer.read() |
| chunks = data.split(b'\x00') | | parts = raw_data.split(b'\x00') |
| utf8_text = chunks[0].decode('utf-8') | | main_text = parts[0].decode('utf-8') |
| fragments = chunks[1:-1] | | segments = parts[1:-1] |
| encodings = ['cp866', 'cp1251', 'koi8_r', 'iso-8859-5'] | | codepages = ['cp866', 'cp1251', 'koi8_r', 'iso-8859-5'] |
| for frag in fragments: | | for item in segments: |
| found = False | | matched = False |
| for enc in encodings: | | for cp in codepages: |
| try: | | try: |
| n | decoded = frag.decode(enc) | n | txt = item.decode(cp) |
| except UnicodeDecodeError: | | except UnicodeDecodeError: |
| continue | | continue |
| n | if decoded in utf8_text: | n | if txt in main_text: |
| found = True | | matched = True |
| break | | break |
| t | print('Yes' if found else 'No') | t | print('Yes' if matched else 'No') |