Problem: Nauuo is a girl who loves playing chess.

One day she invented a game by herself which needs n chess pieces to play on a m× m chessboard. The rows and columns are numbered from 1 to m. We denote a cell on the intersection of the r-th row and c-th column as (r,c).

The game's goal is to place n chess pieces numbered from 1 to n on the chessboard, the i-th piece lies on (r_i,\,c_i), while the following rule is satisfied: for all pairs of pieces i and j, |r_i-r_j|+|c_i-c_j|≥|i-j|. Here |x| means the absolute value of x.

However, Nauuo discovered that sometimes she couldn't find a solution because the chessboard was too small.

She wants to find the smallest chessboard on which she can put n pieces according to the rules.

She also wonders how to place the pieces on such a chessboard. Can you help her?

Input

The only line contains a single integer n (1≤ n≤ 1000) — the number of chess pieces for the game.

Output

The first line contains a single integer — the minimum value of m, where m is the length of sides of the suitable chessboard.

The i-th of the next n lines contains two integers r_i and c_i (1≤ r_i,c_i≤ m) — the coordinates of the i-th chess piece.

If there are multiple answers, print any.

Examples

Input


2


Output


2
1 1
1 2

Input


4


Output


3
1 1
1 3
3 1
3 3

Note

In the first example, you can't place the two pieces on a 1×1 chessboard without breaking the rule. But you can place two pieces on a 2×2 chessboard like this:

<image>

In the second example, you can't place four pieces on a 2×2 chessboard without breaking the rule. For example, if you place the pieces like this:

<image>

then |r_1-r_3|+|c_1-c_3|=|1-2|+|1-1|=1, |1-3|=2, 1<2; and |r_1-r_4|+|c_1-c_4|=|1-2|+|1-2|=2, |1-4|=3, 2<3. It doesn't satisfy the rule.

However, on a 3×3 chessboard, you can place four pieces like this:

<image>

Solution (in JAVA):

Solution:

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.InputStream;

import java.util.ArrayList;
import java.util.Arrays;

import java.util.Comparator;
import java.util.HashMap;

public class Solution {
//    ----------------------------------------------------------------------------

    public static void main(String[] args) throws IOException {

        //IF INPUT-OUTPUT is via files. uncomment use the below 3 lines of code. comment out the next 4
        //     File file = new File("input.txt"); // here input.txt and output.txt being the file names 
        //   InputReader in = new InputReader(new FileInputStream(file));
        //    PrintWriter out = new PrintWriter(new FileOutputStream("output.txt"));
        //ELSE 
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {

            int n = in.nextInt();
            int m = 0;

            int r[] = new int[n + 1];
            int c[] = new int[n + 1];

            if (n == 1) {

                m = 1;
                out.println(m);
                r[1] = 1;
                c[1] = 1;
                out.println(r[1] + " " + c[1]);
                return;
            }

            if (n > 1) {

                // even then m = n+2/2
                //odd then m = n+1/2
                if (n % 2 == 0) {
                    m = (n + 2) / 2;
                } else {

                    m = (n + 1) / 2;
                }

            }
            out.println(m);
            r[1] = 1;
            c[1] = 1;
            r[2] = 1;
            c[2] = 2;
            r[n] = m;
            c[n] = m;
            int col = 2;
            int row = 1;
            
            for (int i = 3; i < n; i++) {

                if (row <m) {
                    r[i] = ++row;
                    c[i] = 2;
                } else {
                    r[i] = m;
                    c[i] = ++col;
                }
            }

            for (int i = 1; i <= n; i++) {

                out.println(r[i] + " " + c[i]);
            }

        }

    }

//    ----------------------------------------------------------------------------
// IMPORTANT || COMMON  METHODS
// PAIR
    static class Pair {

        int x;
        int y;

        // Constructor 
        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

        // how to initialize
//            Pair level[] = new Pair[n];
//            for (int i = 0; i < n; i++) {
//                int x = in.nextInt();
//                int y = in.nextInt();
//
//                level[i] = new Pair(x, y);
//
//            }
        // How to sort
//              PairSort ps = new PairSort();
//              ps.sort(level, 1);
    }

    static class PairSort {

        Pair[] sort(Pair arr[], int i) {
            // Comparator to sort the pair according to second element 
            Arrays.sort(arr, new Comparator<Pair>() {
                @Override
                public int compare(Pair p1, Pair p2) {
                    // 1 sees the first elements ans sorts them in increasing order 
                    // 2 sees the second elements ans sorts them in increasing order 
                    // 3 sees the first elements ans sorts them in decreasing order 
                    // 4 sees the second elements ans sorts them in decreasing order 
                    switch (i) {
                        case 2:
                            return p1.y - p2.y;
                        case 1:
                            return p1.x - p2.x;
                        case 4:
                            return p2.y - p1.y;
                        default:
                            return p2.x - p1.x;
                    }

                }
            });

            return arr;
        }
    }

// GCD || HCF
    static long GCD(long x, long y) {
        return y == 0 ? x : GCD(y, x % y);
    }

    // LCM 
    static long LCM(long a, long b) {
        return (a * b) / GCD(a, b);
    }

    // Returns the divisors of a number
    static ArrayList Divisors(long n) {

//        SO. If you need number of divisors . better to use this
//        same idea as Seive of erasthothenes
//            long[] div = new long[(int) MAX];
//            for (int i = 1; i < MAX; i++) {
//                for (int j = i; j < MAX; j += i) {
//                    div[j]++;
//                }
//            }
        ArrayList<Long> div = new ArrayList<>();

        for (long i = 1; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                div.add(i);

                if (n / i != i) {
                    div.add(n / i);
                }
            }
        }
        return div;
    }

    // PERMUTATIONS
    static void permute(int[] a, int k) {
        if (k == a.length) {

            for (int i = 0; i < k; i++) {

                System.out.print(a[i] + " ");

            }

            System.out.println("");
        } else {
            for (int i = k; i < a.length; i++) {
                int temp = a[k];
                a[k] = a[i];
                a[i] = temp;

                permute(a, k + 1);
                // swapping a[k] and a[i] .
                temp = a[k];
                a[k] = a[i];
                a[i] = temp;

            }
        }

        // How to run 
        //int seq[] = {1, 19, 6}; .. let seq be the array of numbers to be permuted
        //permute(seq, 0); // call this function . 
        //0 -> all permutations ( permutation start from 1st number) 
        //1-> permutations start from 2nd number 
        //2-> permutation start from 3rd number
        // n-1 that array will be returned
    }
//    ----------------------------------------------------------------------------
    // MAIN - INPUT - OUTPUT 

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public Double nextDouble() {
            return Double.parseDouble(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int[] nextIntArray(int arraySize) {
            int array[] = new int[arraySize];

            for (int i = 0; i < arraySize; i++) {
                array[i] = nextInt();
            }

            return array;
        }

    }
}

// to take the string as a single character each . do this.

/*          BufferedReader inn = new BufferedReader(new InputStreamReader(System.in));
            char[] s1 = inn.readLine().toCharArray();
            // for going through each ch in ch array
            for (char c : s1) {
                if (c != ' ') {

                }

            }
 */