Problem: Lunar rover finally reached planet X. After landing, he met an obstacle, that contains permutation p of length n. Scientists found out, that to overcome an obstacle, the robot should make p an identity permutation (make p_i = i for all i).

Unfortunately, scientists can't control the robot. Thus the only way to make p an identity permutation is applying the following operation to p multiple times: 

  * Select two indices i and j (i ≠ j), such that p_j = i and swap the values of p_i and p_j. It takes robot (j - i)^2 seconds to do this operation. 

Positions i and j are selected by the robot (scientists can't control it). He will apply this operation while p isn't an identity permutation. We can show that the robot will make no more than n operations regardless of the choice of i and j on each operation.

Scientists asked you to find out the maximum possible time it will take the robot to finish making p an identity permutation (i. e. worst-case scenario), so they can decide whether they should construct a new lunar rover or just rest and wait. They won't believe you without proof, so you should build an example of p and robot's operations that maximizes the answer.

For a better understanding of the statement, read the sample description.

Input

The first line of input contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases.

Each of next t lines contains the single integer n (2 ≤ n ≤ 10^5) – the length of p.

Note, that p is not given to you. You should find the maximum possible time over all permutations of length n.

It is guaranteed, that the total sum of n over all test cases doesn't exceed 10^5.

Output

For each test case in the first line, print how many seconds will the robot spend in the worst case.

In the next line, print the initial value of p that you used to construct an answer.

In the next line, print the number of operations m ≤ n that the robot makes in your example.

In the each of next m lines print two integers i and j — indices of positions that the robot will swap on this operation. Note that p_j = i must holds (at the time of operation).

Example

Input


3
2
3
3


Output


1
2 1
1
2 1
5
2 3 1
2
1 3
3 2
5
2 3 1
2
1 3
2 3

Note

For n = 2, p can be either [1, 2] or [2, 1]. In the first case p is already identity, otherwise robot will make it an identity permutation in 1 second regardless of choise i and j on the first operation.

For n = 3, p can be equals [2, 3, 1].

  * If robot will select i = 3, j = 2 on the first operation, p will become [2, 1, 3] in one second. Now robot can select only i = 1, j = 2 or i = 2, j = 1. In both cases, p will become identity in one more second (2 seconds in total).
  * If robot will select i = 1, j = 3 on the first operation, p will become [1, 3, 2] in four seconds. Regardless of choise of i and j on the second operation, p will become identity in five seconds. 



We can show, that for permutation of length 3 robot will always finish all operation in no more than 5 seconds.

Solution (in CPP):

Solution:
/*
"0000000000000000000000000010101111110100000000000000000000000000",
"0000000000000000000000101110101010010111110000000000000000000000",
"0000000000000000000011101000100011010000100100000000000000000000",
"0000000000000000011110101011111000011110101110100000000000000000",
"0000000000000000110000001010000011110000101010110000000000000000",
"0000000000000010011011111011101110100101100010010100000000000000",
"0000000000000111001001000000101000111100110110110110000000000000",
"0000000000011111101101101110111011100001100100100011100000000000",
"0000000000111111111111000010000010001011001101101001110000000000",
"0000000001111111111111111111101111111001111001111111111000000000",
"0000000011111111111111111111111111111111111111111111111100000000",
"0000000111111111111111111111111111111111111111111111111110000000",
"0000000111111111111111111111111111111111111111111111111110000000",
"0000001111111111111111111111111111111111111111111111111111000000",
"0000011111111111111111111111111111111111111111111111111111100000",
"0000011111111111111111111111111111111111111111111111111111100000",
"0000111111111111111111111111111111111111111111111111111111110000",
"0001111111111111111111111111111111111111111111111111111111111000",
"0000011111111111111111111111111111111111111111111111111111111000",
"0000000111111111111000100111111111111110001010111111111111100000",
"0011000001111111110010001111111111111110100000001111111100000000",
"0011110000011111000110100011111111111111101101100101100000001100",
"0111111100000100011100111001111111111101001000110000000001111110",
"0111111111000001001001101100011111111101101111100100001111111110",
"0111111111111011011100000111001111111000100100001110111111111110",
"0111111111000001000111011100011111111010111110100010010111111110",
"1111111111110111010010010001001111110010010000110111000111111111",
"1111111111100010010110111011101111010111011110011100010111111111",
"1111111111101111110111100001001010000101001011110001110111111111",
"1111111111100000100100111011100010101101101001000100100111111111",
"1111111111110110111101101110001011100000111101011111101111111111",
"1111111111100011100100100011101001110111100101110001000111111111",
"1111111111111000001101110110111011000001001101100100010111111111",
"1111111111111101101000010100001010010101101000110110111111111111",
"1111111111110000111101010101011110110100101110011100011111111111",
"1111111111111010010001110001111000100110000100110001111111111111",
"1111111111111111000111000101101101101100101110100100111111111111",
"1111111111111111110001011111100000111111100010001111111111111111",
"0111111111111111100100001111101011111111111000100111111111111110",
"0111111111111111111111111111111000011111111111111111111111111110",
"0111111111111111111111111111010010111111111111111111111111111110",
"0111111111111111111111111101000111111111111111111111111111111110",
"0011111111111111111111111100010001111111111111111111111111111100",
"0011111110011111111111111111110111111111111111111111111111111100",
"0001111111010111111111111111100011111111111111111111101111111000",
"0001111111000100011111111111001011111111111011111010000111111000",
"0001111111010101001011100101011001010010110001100000101111111000",
"0000111111110001100000100000001100011000000101001110111111110000",
"0000011111110100111101111011100111000011101111101011111111100000",
"0000011111111110100100100010111101110110100000100011111111100000",
"0000001111111100001101101000010001010000111010001111111111000000",
"0000000111111111011000111110110101000101100011111111111110000000",
"0000000111111111001110010100011100010111001000111111111110000000",
"0000000011111111100011110001110110111101111011111111111100000000",
"0000000001111111110110000101000000100001011111111111111000000000",
"0000000000111111111111010111101101101011001111111111110000000000",
"0000000000011111111111110000111100001000011111111111100000000000",
"0000000000000111111111111111111110111111111111111110000000000000",
"0000000000000011111111111111111111111111111111111100000000000000",
"0000000000000000111111111111111111111111111111110000000000000000",
"0000000000000000011111111111111111111111111111100000000000000000",
"0000000000000000000011111111111111111111111100000000000000000000",
"0000000000000000000000111111111111111111110000000000000000000000",
"0000000000000000000000000011111111111100000000000000000000000000"
IT'S SHOWTIME
HEY CHRISTMAS TREE N
YOU SET US UP 1
HEY CHRISTMAS TREE A
YOU SET US UP 1
HEY CHRISTMAS TREE B
YOU SET US UP 1
HEY CHRISTMAS TREE ANS
YOU SET US UP 1
HEY CHRISTMAS TREE I
YOU SET US UP 1
HEY CHRISTMAS TREE FLAG
YOU SET US UP 1

GET YOUR ASS TO MARS N
DO IT NOW
I WANT TO ASK YOU A BUNCH OF QUESTIONS AND I WANT TO HAVE THEM ANSWERED IMMEDIATELY

GET TO THE CHOPPER A
HERE IS MY INVITATION N
HE HAD TO SPLIT 1000
ENOUGH TALK

GET TO THE CHOPPER B
HERE IS MY INVITATION N
I LET HIM GO 1000
ENOUGH TALK

GET TO THE CHOPPER ANS
HERE IS MY INVITATION 1
ENOUGH TALK

GET TO THE CHOPPER I
HERE IS MY INVITATION A
ENOUGH TALK

GET TO THE CHOPPER FLAG
HERE IS MY INVITATION A
GET UP 1
ENOUGH TALK

GET TO THE CHOPPER FLAG
HERE IS MY INVITATION FLAG
HE HAD TO SPLIT 2
ENOUGH TALK

STICK AROUND FLAG
GET TO THE CHOPPER ANS
HERE IS MY INVITATION ANS
YOU'RE FIRED I
ENOUGH TALK
GET TO THE CHOPPER ANS
HERE IS MY INVITATION ANS
I LET HIM GO B
ENOUGH TALK
GET TO THE CHOPPER I
HERE IS MY INVITATION I
GET DOWN 2
ENOUGH TALK
GET TO THE CHOPPER FLAG
HERE IS MY INVITATION FLAG
GET DOWN 1
ENOUGH TALK
CHILL

TALK TO THE HAND ANS

YOU HAVE BEEN TERMINATED
*/
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,fma,tune=native")
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<cmath>
#include<string.h>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<stack>
#include<sstream>
#include<fstream>
#include<time.h>
#include<bitset>
#include<random>
#include<chrono>
#define ZERO 1e-6
#define pi acos(-1)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define gc getchar()
#define fi first
#define se second
#define ls (o<<1)
#define rs (o<<1|1)
#define test printf("!\n");
#define te(x) printf("%s\n",(x));
#define pr(x) write((x),' ');
using namespace std;

/*
typedef __int128_t lll;

struct frac
{
	ll fi,se;
	
	frac():frac(0,1){}
	
	frac(ll a,ll b):fi(a),se(b){}
	
	bool operator < (const frac & b)
	{
		return (LLL)fi*b.se<(LLL)se*b.fi;
	}
	
	bool operator == (const frac & b)
	{
		return (LLL)fi*b.se==(LLL)se*b.fi;
	}
};

ll fac[MAXN];
ll rev[MAXN];
ll re[MAXN];

ll qpow(ll x,ll n,ll mod=MOD)
{
	ll ans=1;
	
	if(n<0)
	{
		return 1;
	}
	while(n)
	{
		if(n&1)
		{
			ans*=x;
			ans%=mod;
		}
		x*=x;
		x%=mod;
		n>>=1;
	}
	
	return ans;
}

ll inv(ll x)
{
	x%=MOD;
	return qpow(x,MOD-2);
}

void mark()
{
	for(int i=0;i<2;i++)
	{
		fac[i]=rev[i]=re[i]=1;
	}
	for(int i=2;i<MAXN;i++)
	{
		fac[i]=(fac[i-1]*i)%MOD;
		rev[i]=(MOD-MOD/i)*rev[MOD%i]%MOD;
		re[i]=re[i-1]*rev[i]%MOD;
	}
}

ll C(ll x,ll y)
{
	if(x<0||x<y)
	{
		return 0;
	}
	return fac[x]*re[y]%MOD*re[x-y]%MOD;
}

bool isprime[MAXN];
int prime[MAXN];
int prime_cnt;

void mark()
{
	memset(isprime,1,sizeof(isprime));
	isprime[0]=isprime[1]=false;
	prime_cnt=0;
	for(int i=2;i<MAXN;i++)
	{
		if(isprime[i])
		{
			prime[prime_cnt++]=i;
		}
		for(int j=0;j<prime_cnt&&i*prime[j]<MAXN;j++)
		{
			isprime[i*prime[j]]=false;
		}
	}
}

struct edge
{
	int to,nxt;
	ll val;
}es[MAXM];

int edge_tot;
int head[MAXN];

void addedge(int u,int v,ll val=1)
{
	es[edge_tot]=edge{v,head[u],val};
	head[u]=edge_tot++;
}

void add(int u,int v,ll val=1)
{
	addedge(u,v,val);
	addedge(v,u,val);
}
*/

typedef unsigned long long ull;
typedef long long ll;
const int MAXN=2e5+10;
const int MAXM=4e6+10;
const ll MOD=1e9+7;
const ll INF=0x3f3f3f3f;
const ll LIM=450;
const ull BASE=233;
const int base=5;
mt19937_64 mt(time(0));

char rubbish[110];
bool GETDATA;
bool PRINT;
const int CHECK=-1;
const int TARGET=-1;

inline ll read()
{
	ll x=0,f=1;
	char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-48;ch=getchar();}while(ch>='0'&&ch<='9');
	return x*f;
}

inline void write(ll x,char con='\n')
{
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10,0);
	putchar(x%10+'0');
	if(con)putchar(con);
}

ll N,M,K,Q;
ll a[MAXN];

void init()
{
	M=N>>1;
}

void solve()
{
	ll ans=0;
	int p;
	
	N=read();
	init();
	p=N;
	for(int i=2;i<=M;i++)
	{
		a[p]=i;
		p=i;
		ans+=(N-i)*(N-i);
	}
	a[p]=1;
	p=1;
	for(ll i=M+1;i<=N;i++)
	{
		a[p]=i;
		p=i;
		ans+=(i-1)*(i-1);
	}
	write(ans);
	for(int i=1;i<=N;i++)
	{
		write(a[i],i==N?'\n':' ');
	}
	write(N-1);
	for(int i=2;i<=M;i++)
	{
		pr(i) write(N);
	}
	for(int i=M+1;i<=N;i++)
	{
		pr(i) write(1);
	}
}

int main()
{
	int T;
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	T=1;
	T=read();
	GETDATA=T==CHECK;
	for(int t=1;t<=T;t++)
	{
		PRINT=t==TARGET;
		solve();
	}
	
	return 0;
}
/*


*/