Problem: You have an array a_1, a_2, ..., a_n where a_i = i.

In one step, you can choose two indices x and y (x ≠ y) and set a_x = \left⌈ (a_x)/(a_y) \right⌉ (ceiling function).

Your goal is to make array a consist of n - 1 ones and 1 two in no more than n + 5 steps. Note that you don't have to minimize the number of steps.

Input

The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases.

The first and only line of each test case contains the single integer n (3 ≤ n ≤ 2 ⋅ 10^5) — the length of array a.

It's guaranteed that the sum of n over test cases doesn't exceed 2 ⋅ 10^5.

Output

For each test case, print the sequence of operations that will make a as n - 1 ones and 1 two in the following format: firstly, print one integer m (m ≤ n + 5) — the number of operations; next print m pairs of integers x and y (1 ≤ x, y ≤ n; x ≠ y) (x may be greater or less than y) — the indices of the corresponding operation.

It can be proven that for the given constraints it's always possible to find a correct sequence of operations.

Example

Input


2
3
4


Output


2
3 2
3 2
3
3 4
4 2
4 2

Note

In the first test case, you have array a = [1, 2, 3]. For example, you can do the following: 

  1. choose 3, 2: a_3 = \left⌈ (a_3)/(a_2) \right⌉ = 2 and array a = [1, 2, 2]; 
  2. choose 3, 2: a_3 = \left⌈ 2/2 \right⌉ = 1 and array a = [1, 2, 1]. 

You've got array with 2 ones and 1 two in 2 steps.

In the second test case, a = [1, 2, 3, 4]. For example, you can do the following: 

  1. choose 3, 4: a_3 = \left⌈ 3/4 \right⌉ = 1 and array a = [1, 2, 1, 4]; 
  2. choose 4, 2: a_4 = \left⌈ 4/2 \right⌉ = 2 and array a = [1, 2, 1, 2]; 
  3. choose 4, 2: a_4 = \left⌈ 2/2 \right⌉ = 1 and array a = [1, 2, 1, 1]. 

Solution (in JAVA):

Solution:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solve(in, out);
        out.close();
    }

    static String reverse(String s) {
        return (new StringBuilder(s)).reverse().toString();
    }

    static void sieveOfEratosthenes(int n, int factors[]) 
    { 
        factors[1]=1;
        for(int p = 2; p*p <=n; p++) 
        { 
            if(factors[p] == 0) 
            { 
                factors[p]=p;
                for(int i = p*p; i <= n; i += p) 
                    factors[i] = p; 
            } 
        } 
    }

    static void sort(int ar[]) {
        int n = ar.length;
        ArrayList<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++)
            a.add(ar[i]);
        Collections.sort(a);
        for (int i = 0; i < n; i++)
            ar[i] = a.get(i);
    }

    static void sort1(long ar[]) {
        int n = ar.length;
        ArrayList<Long> a = new ArrayList<>();
        for (int i = 0; i < n; i++)
            a.add(ar[i]);
        Collections.sort(a);
        for (int i = 0; i < n; i++)
            ar[i] = a.get(i);
    }

    static long ncr(long n, long r, long mod) {
        if (r == 0)
            return 1;
        long val = ncr(n - 1, r - 1, mod);
        val = (n * val) % mod;
        val = (val * modInverse(r, mod)) % mod;
        return val;
    }

    static void findHash(String s, long hash[], int len, long m, long p[]){
        for(int i=0;i<len;i++){
            hash[i+1] = ( hash[i] + ( s.charAt(i) - 96 ) * p[i] % m ) % m;
        }
    }

    public static void solve(InputReader sc, PrintWriter pw) {
        int i, j = 0;
        // int t = 1;  
        int t = sc.nextInt();
        u: while (t-- > 0) {
            int n = sc.nextInt();
            int y = n;
            int v = 0;
            if(y<=256){
                while(y>1){
                    y=(y+1)/2;
                    v++;
                }
                pw.println(n-3+v);
                for(i=3;i<n;i++){
                    pw.println(i+" "+(i+1));
                }
                for(i=0;i<v;i++)
                    pw.println(n+" "+2);
            }
            else if(y<=512){
                int v1 = 0, v2 = 0, v3 = 0;
                while(y>1){
                    y=(y+15)/16;
                    v2++;
                }
                y = 16;
                while(y>1){
                    y=(y+3)/4;
                    v3++;
                }
                pw.println(n-5+v1+v2+v3+2);
                for(i=3;i<n;i++){
                    if(i!=4&&i!=16)
                        pw.println(i+" "+(i+1));
                }
                // for(i=101;i<n;i++){
                //     pw.println(i+" "+(i+1));
                // }
                // for(i=0;i<v1;i++)
                //     pw.println(n+" "+512);
                for(i=0;i<v2;i++)
                    pw.println(n+" "+16);
                for(i=0;i<v3;i++)
                    pw.println(16+" "+4);
                for(i=0;i<2;i++)
                    pw.println(4+" "+2);
            }
            else{
                int v1 = 0, v2 = 0, v3 = 0;
                while(y>1){
                    y=(y+511)/512;
                    v1++;
                }
                y = 512;
                while(y>1){
                    y=(y+15)/16;
                    v2++;
                }
                y = 16;
                while(y>1){
                    y=(y+3)/4;
                    v3++;
                }
                // y = 4;
                // while(y>1){
                //     y=(y+1)/2;
                //     v2++;
                // }
                pw.println(n-6+v1+v2+v3+2);
                for(i=3;i<n;i++){
                    if(i!=4&&i!=16&&i!=512)
                        pw.println(i+" "+(i+1));
                }
                // for(i=101;i<n;i++){
                //     pw.println(i+" "+(i+1));
                // }
                for(i=0;i<v1;i++)
                    pw.println(n+" "+512);
                for(i=0;i<v2;i++)
                    pw.println(512+" "+16);
                for(i=0;i<v3;i++)
                    pw.println(16+" "+4);
                for(i=0;i<2;i++)
                    pw.println(4+" "+2);
                // pw.println(n-6+v1+v2+v3+2);
            }
        }
    }

    static class Pair1 {
        long a;
        long b;
        
        Pair1(long a, long b) {
            this.a = a;
            this.b = b;
        }
    }

    static class Pair implements Comparable<Pair> {
        int a;
        int b;
        
        Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }
 
        public int compareTo(Pair p) {
            if(a!=p.a)
                return a-p.a;
            return b-p.b;
        }
    }

    static boolean isPrime(long n) {
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;
        if (n % 2 == 0 || n % 3 == 0)
            return false;
        for (int i = 5; i * i <= n; i = i + 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;
        return true;
    }

    static long gcd(long a, long b) {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }

    static long fast_pow(long base, long n, long M) {
        if (n == 0)
            return 1;
        if (n == 1)
            return base % M;
        long halfn = fast_pow(base, n / 2, M);
        if (n % 2 == 0)
            return (halfn * halfn) % M;
        else
            return (((halfn * halfn) % M) * base) % M;
    }

    static long modInverse(long n, long M) {
        return fast_pow(n, M - 2, M);
    }

    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 long nextLong() {
            return Long.parseLong(next());
        }
    }
}