fork download
  1. def h(d, s, a, t):
  2. if d == 1:
  3. print('{} {}'.format(s, t))
  4. return
  5.  
  6. h(d - 1, s, t, a)
  7. print('{} {}'.format(s, t))
  8. h(d - 1, a, s, t)
  9.  
  10. n=int(input())
  11. print(2**n-1)
  12. h(n,'1','2','3')
Success #stdin #stdout 0.03s 9640KB
stdin
3
stdout
7
1 3
1 2
3 2
1 3
2 1
2 3
1 3