//用个map<int,int>或pair,按int 1...n顺序倒入队列,按题意算法模拟,给map【x】赋值再打印即可

#include<vector>
#include<iostream>
#include<stdio.h>
#include<map>
using namespace std;

int main(void)
{
    int T;
    int n;
    cin>>T;
    while(T--)
    {
        
        cin>>n;
        
        queue<int> Q;
        
        map<int,int> mp;
        
        for(int i=1;i<=n;i++)
            Q.push(i);
        
        for(int i=1;i<=n;i++)
        {
            auto x = Q.front();
            
            Q.pop();
            
            Q.push(x);
           
            x = Q.front();
            
            mp[x] = i;
            
            Q.pop();
        }
        
        for(int i=0;i<n;i++) cout<<mp[i+1]<<" ";
        cout<<endl;
        
    }
    
    return 0;
}