ss = [] def vb(x, y, s=0): if s == 2: ss.append(str(y) + str(x)) else: if x > 1 and y > 2: vb(x - 1, y - 2, s+ 1) if x > 2 and y > 1: vb(x - 2, y - 1, s + 1) if x < 8 and y > 2: vb(x + 1, y - 2, s + 1) if x < 7 and y > 1: vb(x + 2, y - 1, s + 1) if x < 7 and y < 8: vb(x + 2, y + 1, s + 1) if x < 8 and y < 7: vb(x + 1, y + 2, s + 1) if x > 1 and y < 7: vb(x - 1, y + 2, s + 1) if x > 2 and y < 8: vb(x - 2, y + 1, s + 1) f=input() g = input() g = int(g) f = {'1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8}[f] vb(f, g) ss = ['12345678'[int(i[1]) - 1] +' '+ i[0] for i in sorted(set(ss), key=lambda i: int(i))] for i in ss: print(i)