f | import string | f | import string |
| import sys | | import sys |
| | | |
| class Pairs: | | class Pairs: |
n | __slots__ = ('_offset',) | n | __slots__ = '_start' |
| | | |
n | def __init__(self, initial_value): | n | def __init__(self, N): |
| self._offset = initial_value | | self._start = N |
| | | |
n | def __getattr__(self, attribute): | n | def __getattr__(self, name): |
| if attribute in string.ascii_letters: | | if name in string.ascii_letters: |
| char_index = string.ascii_letters.index(attribute) + 1 | | i = string.ascii_letters.index(name) + 1 |
| alphabet_size = len(string.ascii_letters) | | l = len(string.ascii_letters) |
| mapped_value = (self._offset + char_index - 2) % alphabet_si | | val = (self._start + i - 2) % l + 1 |
| ze + 1 | | |
| return mapped_value | | return val |
| | | |
n | def __setattr__(self, attribute, value): | n | def __setattr__(self, name, val): |
| if attribute in string.ascii_letters: | | if name in string.ascii_letters: |
| char_index = string.ascii_letters.index(attribute) + 1 | | i = string.ascii_letters.index(name) + 1 |
| adjustment = (value - char_index) % len(string.ascii_letters | | step = (val - i) % len(string.ascii_letters) |
| ) | | |
| self._offset = 1 + adjustment | | self._start = 1 + step |
| else: | | else: |
n | super().__setattr__(attribute, value) | n | super().__setattr__(name, val) |
| | | |
| def __str__(self): | | def __str__(self): |
t | alphabet_size = len(string.ascii_letters) | t | l = len(string.ascii_letters) |
| reordered = [None] * alphabet_size | | ans = [None] * l |
| for idx, char in enumerate(string.ascii_letters): | | for i, c in enumerate(string.ascii_letters): |
| mapped_position = (self._offset + idx - 1) % alphabet_size + | | val = (self._start + i - 1) % l + 1 |
| 1 | | |
| reordered[mapped_position - 1] = char | | ans[val - 1] = c |
| return ' '.join(reordered) | | return ' '.join(ans) |
| exec(sys.stdin.read()) | | exec(sys.stdin.read()) |