代码如下
#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for(int x=y;x<=z;x++)
#define per(x,y,z) for(int x=y;x>=z;x--)
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define endl '\n'
typedef long long LL;
const int N=2e5+5,MOD=1e6+7;
int n;
void solve(){
cin>>n;
int res=0;
rep(i,1,n) res+=i*(2*i-1);
cout<<res<<" "<<2*n<<endl;
cout<<"1 1 ";
rep(i,1,n) cout<<i<<" ";
cout<<endl;
rep(i,2,n){
cout<<"2 "<<i<<" ";
rep(j,1,n) cout<<j<<" ";
cout<<endl;
}
rep(i,1,n-1){
cout<<"1 "<<i<<" ";
rep(j,1,n) cout<<j<<" ";
cout<<endl;
}
cout<<"2 1 ";
rep(j,1,n) cout<<j<<" ";
cout<<endl;
}
int main(){
IOS;
int T;
cin>>T;
while(T--){
solve();
}
return 0;
}