1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define fo(i,n) for(i=0;i<n;i++)
  5. #define int long long
  6. #define deb(x) cout << #x << "=" << x << endl
  7. #define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
  8. #define deb3(x, y, z) cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
  9. #define pb push_back
  10. #define mp make_pair
  11. #define all(x) x.begin(), x.end()
  12. #define clr(x) memset(x, 0, sizeof(x))
  13. #define sortall(x) sort(all(x))
  14. #define el cout<<"\n"
  15. #define max3(a,b,c) max(max((a),(b)),(c))
  16. #define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))
  17. #define min3(a,b,c) min(min((a),(b)),(c))
  18. #define min4(a,b,c,d) min(min((a),(b)),min((c),(d)))
  19. /////////////////////
  20. int dx[] = {0, 0, -1, 1, 1, 1, -1, -1};
  21. int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
  22.  
  23. //////////////////for vectors
  24. # define maxv(a) (*max_element(a.begin(),a.end()))
  25. # define minv(a) (*min_element(a.begin(),a.end()))
  26. # define sumvi(a) (accumulate(a.begin(),a.end(),0LL))
  27. # define sumvd(a) (accumulate(a.begin(),a.end(),double(0)))
  28.  
  29. # define printv(v) {auto i = v;for(auto j : i) cout<< j << ' ';cout << "\n";}
  30. # define printvv(v) {auto i = v;for(auto j : i) {for(auto k : j) cout<< k << ' ';cout << "\n";}}
  31. # define prints(s) {auto i = s;for(auto j : i) cout<< j << ' ';cout << "\n";}
  32. # define printm(m) {auto i = m;for(auto j : i) cout<< j.first << ':' << j.second << ' ';cout << "\n";}
  33.  
  34. /////////////////////////
  35. typedef pair<int, int> pii;
  36. typedef vector<int> vi;
  37. typedef vector<pii> vpii;
  38. typedef vector<vi> vvi;
  39. /////////////////////////
  40. mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
  41. int rng(int lim) {
  42. uniform_int_distribution<int> uid(0, lim - 1);
  43. return uid(rang);
  44. }
  45. /////////////////////
  46. const int inf = 1e9;
  47. const int INF = 1e18;
  48. const int mod = 1000000007;
  49. // const int mod = 998244353;
  50. const int N = 3e5 + 5, M = N;
  51. ////////////////
  52. int total = 0;
  53. void solve() {
  54.  
  55. int i, j, n, k;
  56. cin >> n;
  57. total += n;
  58. assert( n >= 1 && n <= 100000);
  59. vi ans;
  60. if (n == 3) {
  61. cout << "3 2 1\n";
  62. }
  63. else {
  64. ans.pb(n);
  65. ans.pb(n - 2);
  66. for (int i = 1 ; i < n - 3 ; i++) ans.pb(i);
  67. ans.pb(n - 3);
  68. ans.pb(n - 1);
  69. printv(ans);
  70. }
  71.  
  72.  
  73. }
  74.  
  75. int32_t main() {
  76. ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  77. srand(chrono::high_resolution_clock::now().time_since_epoch().count());
  78. int t = 1;
  79. cin >> t;
  80. while (t--) {
  81. solve();
  82. }
  83. assert(total <= 300000);
  84. return 0;
  85. }