1. //Utkarsh.25dec
  2. #include <bits/stdc++.h>
  3. #define ll long long int
  4. #define pb push_back
  5. #define mp make_pair
  6. #define mod 1000000007
  7. #define vl vector <ll>
  8. #define all(c) (c).begin(),(c).end()
  9. using namespace std;
  10. ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
  11. ll modInverse(ll a){return power(a,mod-2);}
  12. const int N=500023;
  13. bool vis[N];
  14. vector <int> adj[N];
  15. long long readInt(long long l,long long r,char endd){
  16. long long x=0;
  17. int cnt=0;
  18. int fi=-1;
  19. bool is_neg=false;
  20. while(true){
  21. char g=getchar();
  22. if(g=='-'){
  23. assert(fi==-1);
  24. is_neg=true;
  25. continue;
  26. }
  27. if('0'<=g && g<='9'){
  28. x*=10;
  29. x+=g-'0';
  30. if(cnt==0){
  31. fi=g-'0';
  32. }
  33. cnt++;
  34. assert(fi!=0 || cnt==1);
  35. assert(fi!=0 || is_neg==false);
  36.  
  37. assert(!(cnt>19 || ( cnt==19 && fi>1) ));
  38. } else if(g==endd){
  39. if(is_neg){
  40. x= -x;
  41. }
  42.  
  43. if(!(l <= x && x <= r))
  44. {
  45. cerr << l << ' ' << r << ' ' << x << '\n';
  46. assert(1 == 0);
  47. }
  48.  
  49. return x;
  50. } else {
  51. assert(false);
  52. }
  53. }
  54. }
  55. string readString(int l,int r,char endd){
  56. string ret="";
  57. int cnt=0;
  58. while(true){
  59. char g=getchar();
  60. assert(g!=-1);
  61. if(g==endd){
  62. break;
  63. }
  64. cnt++;
  65. ret+=g;
  66. }
  67. assert(l<=cnt && cnt<=r);
  68. return ret;
  69. }
  70. long long readIntSp(long long l,long long r){
  71. return readInt(l,r,' ');
  72. }
  73. long long readIntLn(long long l,long long r){
  74. return readInt(l,r,'\n');
  75. }
  76. string readStringLn(int l,int r){
  77. return readString(l,r,'\n');
  78. }
  79. string readStringSp(int l,int r){
  80. return readString(l,r,' ');
  81. }
  82. int sumN=0;
  83. void solve()
  84. {
  85. int n=readInt(3,100000,'\n');
  86. sumN+=n;
  87. assert(sumN<=300000);
  88. if(n==3)
  89. {
  90. cout<<"2 1 3\n";
  91. return;
  92. }
  93. int A[n+1]={0};
  94. A[1]=n;
  95. A[n]=n-1;
  96. A[2]=n-2;
  97. A[n-1]=n-3;
  98. int ele=n-4;
  99. for(int i=3;i<n-1;i++)
  100. A[i]=ele--;
  101. for(int i=1;i<=n;i++)
  102. cout<<A[i]<<' ';
  103. cout<<'\n';
  104. }
  105. int main()
  106. {
  107. #ifndef ONLINE_JUDGE
  108. freopen("input.txt", "r", stdin);
  109. freopen("output.txt", "w", stdout);
  110. #endif
  111. ios_base::sync_with_stdio(false);
  112. cin.tie(NULL),cout.tie(NULL);
  113. int T=readInt(1,1000,'\n');
  114. while(T--)
  115. solve();
  116. assert(getchar()==-1);
  117. cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
  118. }