#include <iostream>
#include<unordered_map>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
long long int p=1e9+7;
#define endl '\n';
int main() {
   
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t=1;
   cin>>t;
 
  while(t--)
  {
     
     
     
     
     
     
     int n;
     cin>>n;
     vector<int> v;
     for(int i=n;i>=1;i--)
     {
         v.push_back(i);
     }
     
     if(n%2==1)
     {
         int a=v[n/2];
         v[n/2]=v[n-1];
         v[n-1]=a;
     }
     
     for(int i=0;i<n;i++)
     {
         cout<<v[i]<<" ";
     }
     
     
     
     
     cout<<endl;
     
      
  }
  
  
  
  return 0;
       
      }
    
  
    

  
    
    
