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

mt19937 rng(time(0));

long long randint(long long a, long long b){
    uniform_int_distribution<long long> dist(a, b);
    return dist(rng);
}

const int swapXY[] = {0, 2, 1, 4, 3};

long long findScore(long long a, long long b){
    long long A = a;
    long long B = b;
    long long score = 0;
    while(b){
        score += a/b;
        long long c = b;
        long long d = a%b;
        a = c;
        b = d;
    }

    score += a;
    assert(a == __gcd(A, B));
    return score;
}

vector<int> ans;
void findScore2(long long a, long long b){
    long long A = a;
    long long B = b;
    long long score = 0;
    while(a && b){
        //printf("%lld %lld\n", a, b);
        while(a >= b && b > 0){
            a -= b;
            score ++;
            ans.push_back(3);
        }

        while(b >= a && a > 0){
            b -= a;
            score ++;
            ans.push_back(4);
        }
    }

    while(a){
        //printf("%lld %lld\n", a, b);
        a --;
        score ++;
        ans.push_back(1);
    }

    while(b){
        //printf("%lld %lld\n", a, b);
        b --;
        score ++;
        ans.push_back(2);
    }

    reverse(ans.begin(), ans.end());
    assert(score == findScore(A, B));
}

long double phi = (sqrt(5.0L)+1)/2;

int main(){
    long long N;
    scanf("%lld", &N);

    long long bestScore = 1LL << 60;
    long long bestI = rint(N*phi);
    while(findScore(N, bestI) > 130){
        bestI ++;
    }

    findScore2(N, bestI);

    long long x = 0;
    long long y = 0;

    int K = (int)ans.size();
    for(int i = 0; i < K; i ++){
        if(ans[i] == 1){
            x ++;
        }else if(ans[i] == 2){
            y ++;
        }else if(ans[i] == 3){
            x += y;
        }else if(ans[i] == 4){
            y += x;
        }else{
            assert(ans[i] <= 4 && ans[i] >= 1);
        }
    }

    //printf("x=%lld y=%lld\n", x, y);

    assert(x == N);
    printf("%d\n", K);
    for(int i: ans){
        printf("%d\n", i);
    }

    return 0;
}

#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }



int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cout << (i*2+1)%n+1 << " " << (i*2)%n+1 << "\n";
    }
    return 0;
}