#include <bits/stdc++.h>
using namespace std;
using ll=long long;

void hanoi(int st,int en, int n){
    if(n==1) {
        cout << st << ' ' << en << '\n';
        return;
    }
    hanoi(st,6-st-en,n-1);
    cout << st << ' ' << en << '\n';
    hanoi(6-st-en,en,n-1);
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    cout << (1<<n) -1 <<'\n';
    hanoi(1,3,n);
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: