w, h = int(input()), int(input())
qr_code = [list(input()) for _ in range(h)]
def clean(arr):
new_arr = [row[:] for row in arr]
n, m = len(arr), len(arr[0])
for x, y in ((1, 2), (1, m - 3), (n - 2, 2), (n - 3, m - 5)):
c = arr[x][y]
max_u = 1 if c == 'X' else 2
max_v = 1 if c == 'X' else 3
for u in range(x - max_u, x + max_u + 1):
for v in range(y - max_v, y + max_v + 1):
if 0 <= u < n and 0 <= v < m:
new_arr[u][v] = '@'
return new_arr
code = clean(qr_code)
print('\n'.join(''.join(row) for row in code))
def get_chr(arr, k=None):
ans = []
x = int(''.join(map(str, arr)), 2)
if not k is None:
x ^= k
return chr(x)
def pos_gen(arr):
ans = []
n, m = len(arr), len(arr[0])
bit = 0
x, y, dx = n, m - 1, -1
step = 0
while step + 57 < n * m:
bit = 1 - bit
x += dx
if x < 0 and y > 0:
x, y, dx = 0, y - 1, -dx
elif x >= n and y > 0:
x, y, dx = n - 1, y - 1, -dx
c = arr[x][y]
if c != '@':
r = (1 if c != ' ' else 0) ^ bit
ans.append(r)
step += 1
return ans
data = pos_gen(code)
bom, txt = data[:8], data[8: ]
encrypted, key = False, None
if bom[0] == 0:
encrypted = True
key = int(''.join(map(str, bom[1:])), 2)
l = len(txt)
ans = []
print(l, l % 7)
for i in range(0, l, 7):
st = get_chr(txt[i: i + 7], k=key)
ans.append(st)
print(ans)
To embed this program on your website, copy the following code and paste it into your website's HTML: