while True:
x_in, y_in = raw_input()
cells = []
for x_test in 'abcdefgh':
for y_test in '12345678':
x_diff = ord(x_test) - ord(x_in)
y_diff = ord(y_test) - ord(y_in)
dist_square = x_diff ** 2 + y_diff**2
if dist_square == 5:
cell = x_test + y_test
cells.append(cell)
print' '.join(cells)
Note that non-ascii characters in the above source code will be escaped (such as \x9f).