# 사실 하노이는 2 ^ 원반의 갯수 - 1을 해서 프린트 해주면
# 이런식으로 리스트는 사용하지 않아도 됩니다.(쓴 이유 : 그냥..)

K = int(input())
print_list = []

def hanoi(num, a, b, c, print_list):
    if(num == 1):
        print_list.append([a, c])
        return None
    
    hanoi(num - 1, a, c, b, print_list)
    print_list.append([a, c])
    hanoi(num - 1, b, a, c, print_list)
hanoi(K, 1, 2, 3, print_list)

print(len(print_list))
for a, b in print_list:
    print('{} {}'.format(a, b))

 

'# 코딩 문제 관련 > 파이썬' 카테고리의 다른 글

백준 3052번(python)  (0) 2019.07.03
백준 10818번(python)  (0) 2019.07.03
백준 2447번(python)  (4) 2019.06.28
백준 10872번(python)  (0) 2019.06.27
백준 10870번(python)  (0) 2019.06.27