#include
#include
#include
using namespace std;
void rec(int N, int first_tower, int second_tower, int third_tower) {
if(N == 0) {
return;
}
rec(N - 1, first_tower, third_tower, second_tower);
cout << first_tower << " " << third_tower << endl;
rec(N - 1, second_tower, first_tower, third_tower);
}
int main() {
int N;
cin >> N;
cout << (1 << N) - 1 << endl;
rec(N, 1, 2, 3);
return 0;
}