Numbers $1, 2, 3, \dots n$ (each integer from $1$ to $n$ once) are written on a board. In one operation you can erase any two numbers $a$ and $b$ from the board and write one integer $\frac{a + b}{2}$ rounded up instead.

You should perform the given operation $n - 1$ times and make the resulting number that will be left on the board as small as possible. 

For example, if $n = 4$, the following course of action is optimal:  choose $a = 4$ and $b = 2$, so the new number is $3$, and the whiteboard contains $[1, 3, 3]$;  choose $a = 3$ and $b = 3$, so the new number is $3$, and the whiteboard contains $[1, 3]$;  choose $a = 1$ and $b = 3$, so the new number is $2$, and the whiteboard contains $[2]$. 

It's easy to see that after $n - 1$ operations, there will be left only one number. Your goal is to minimize it.


-----Input-----

The first line contains one integer $t$ ($1 \le t \le 1000$) — the number of test cases.

The only line of each test case contains one integer $n$ ($2 \le n \le 2 \cdot 10^5$) — the number of integers written on the board initially.

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


-----Output-----

For each test case, in the first line, print the minimum possible number left on the board after $n - 1$ operations. Each of the next $n - 1$ lines should contain two integers — numbers $a$ and $b$ chosen and erased in each operation.


-----Example-----
Input
1
4

Output
2
2 4
3 3
3 1

Starter code:

Solutions:
t=int(input())
for i in range(t):
    n=int(input())
    print(2)
    print(n-1,n)
    for i in range(n-2,0,-1):
        print(i,i+2)

for _ in range (int(input())):
    n=int(input())
    hold=n
    res=[]
    for i in range (n-1,0,-1):
        res.append((hold,i))
        hold=(hold+i+1)//2
    print(hold)
    for i in res:
        print(*i)

t = int(input())
for _ in range(t):
    n = int(input())
    print(2)
    print(n-1, n)
    for i in range(n-2):
        print(n-2-i, n-i)

import sys
import random
# import numpy as np
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)
# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")

MOD = 10 ** 9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def judge(at, ax, ay, bt, bx, by):
    if abs(at - bt) >= abs(ax - bx) + abs(ay - by):
        return True
    else:
        return False


def solve():
    n = getN()
    if n == 2:
        print(2)
        print(1, 2)
        return

    print(2)
    print(n-2, n)
    print(n-1, n-1)
    for i in range(n-3):
        print(n-1-i, n-3-i)
    return

def main():
    n = getN()
    for _ in range(n):
        solve()

    return
def __starting_point():
    main()
    # solve()

__starting_point()

t=int(input())
for you in range(t):
    n=int(input())
    print(2)
    l=[i+1 for i in range(n)]
    for i in range(n-1):
        print(l[-1],l[-2])
        z=(l[-1]+l[-2]+1)//2
        l.pop(-1)
        l.pop(-1)
        l.append(z)


for _ in range(int(input())):
    n = int(input())
    k = n
    print(2)
    for i in range(n-1,0,-1):
        print(i,k)
        if (k+i)%2!= 0:
            k = (k+i)//2 + 1
        else:
            k = (k+i)//2
        


import sys
input = sys.stdin.readline

t = int(input())
for i in range(t):
    n = int(input())
    print(2)
    if n == 2:
        print(1,2)
    else:
        print(n,n-2)
        print(n-1,n-1)
        for j in range(n-3):
            print(n-1-j,n-1-j-2)   

#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
#import io,os; input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline #for pypy
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

for _ in range(inp()):
    n = inp()
    prev = n
    print(2)
    for i in range(n-1,0,-1):
        print(i,prev)
        prev = (i+prev-1)//2 +1

T =  int(input())
for _ in range(T):
    N = int(input())
    A = list(range(1,N+1))
    print(2)
    while len(A) > 1:
        a = A.pop()
        b = A.pop()
        c = (a+b+1)//2
        print(a,b)
        A.append(c)


import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
#from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var) : sys.stdout.write('\n'.join(map(str, var))+'\n')
def out(var) : sys.stdout.write(str(var)+'\n')
#from decimal import Decimal
#from fractions import Fraction
#sys.setrecursionlimit(100000)
INF = float('inf')
mod=10**9+7


for t in range(int(data())):
    n=int(data())
    out(2)
    ans=[]
    k=n
    for i in range(n-1,0,-1):
        ans.append(str(k)+' '+str(i))
        k=(k+i+1)//2
    outl(ans)


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop,heapify
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline

from itertools import accumulate
from functools import lru_cache

M = mod = 10 ** 9 + 7
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)
 
def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]


for _ in range(val()):
    n = val()
    
    print(2)
    l = list(range(1, n + 1))
    for i in range(n - 1):
        a, b = l.pop(), l.pop()
        print(a, b)
        l.append((a + b + 1) // 2)


from math import ceil

n = int(input())

for _ in range(n):
    k = int(input())
    
    arr = list(range(1, k+1))
    o = []

    for i in range(k-1):
        a = arr.pop()
        b = arr.pop()
        o.append((a, b))
        arr.append(ceil((a+b)/2))

    print(arr[0])
    for i in range(len(o)):
        print(o[i][0], o[i][1])
    


import sys
input = sys.stdin.readline


def main():
    t = int(input())
    for _ in range(t):
        N = int(input())

        x = []
        for i in range(1, N + 1):
            x.append(i)

        print(2)

        while len(x) >= 2:
            a = x.pop()
            b = x.pop()
            c = -(-(a + b) // 2)
            print(a, b)
            x.append(c)

        
    

def __starting_point():
    main()



__starting_point()

t = int(input())
ns = []
for _ in range(t):
    n = int(input())
    ns.append(n)

for n in ns:
    print(2)
    print(n-1, n)
    if n > 2:
        for x in range(n, 2, -1):
            print(x-2, x)


t = int(input())

for _ in range(t):
    n = int(input())

    print(2)
    print('{0} {1}'.format(n-1, n))

    for k in range(n, 2, -1):
        print('{0} {1}'.format(k-2, k))


def solve():
    n = int(input())
    if n == 2:
        print(2)
        print(1, 2)
        return 0
    lst = list(range(1, n + 1))
    ans = []
    ans.append([n-2,n])
    ans.append([n-1,n-1])
    lst.pop()
    lst.pop()
    lst.pop()
    lst.append(n-1)
    while len(lst) > 1:
        a = lst[-1]
        b = lst[-2]
        c = (a + b + 1) // 2
        ans.append([a,b])
        lst.pop()
        lst.pop()
        lst.append(c)
    print(lst[0])
    for i in ans:
        print(*i)
for i in range(int(input())):
    solve()

import sys
input = sys.stdin.readline

t=int(input())
for tests in range(t):
    n=int(input())
    print(2)
    x=n
    for i in range(n-1,0,-1):
        print(x,i)
        x=(x+i+1)//2

    

    


"""T=int(input())
for _ in range(0,T):
    n=int(input())
    a,b=map(int,input().split())
    s=input()
    s=[int(x) for x in input().split()]
    for i in range(0,len(s)):
        a,b=map(int,input().split())"""


T=int(input())
for _ in range(0,T):
    n=int(input())
    print(2)

    num=n
    for i in range(n-1,0,-1):
        print(i,num)
        if((num+i)%2==0):
            num=(num+i)//2

            
        


t = int(input())
for _ in range(t):
    n = int(input())
    A = list(range(1, n+1))
    ans = []
    t = -1
    for i in range(n-1):
        ans.append((A[-2], A[-1]))
        x = A.pop()
        if (x+A[-1])%2 == 0:
            A[-1] = (x+A[-1])//2
        else:
            A[-1] = (x+A[-1]+1)//2
    print(A[0])
    for i in range(len(ans)):
        print(*ans[i])


for _ in range(int(input())):
    n = int(input())
    print(2, flush=False)
    print(f'{n} {n-1}', flush=False)
    if n > 2:
        print('\n'.join(f'{x} {x-2}' for x in range(n, 2, -1)))


# 3x + 5y + 7z

t = int(input())

while t:
    t -= 1
    n = int(input())
    print(2)
    arr = [n-1,n]
    print(*arr)
    for i in range(2,n):
        arr = [n-i,n-i+2]
        print(*arr)