codeforces1454A. Special Permutation

终于知道为什么总是不过测试点2了!!

A. Special Permutation

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

You are given one integer nn (n>1n>1).

Recall that a permutation of length nn is an array consisting of nn distinct integers from 11 to nn in arbitrary order. For example, [2,3,1,5,4][2,3,1,5,4] is a permutation of length 55, but [1,2,2][1,2,2] is not a permutation (22 appears twice in the array) and [1,3,4][1,3,4] is also not a permutation (n=3n=3 but there is 44 in the array).

Your task is to find a permutation pp of length nn that there is no index ii (1≤i≤n1≤i≤n) such that pi=ipi=i (so, for all ii from 11 to nn the condition pi≠ipi≠i should be satisfied).

You have to answer tt independent test cases.

If there are several answers, you can print any. It can be proven that the answer exists for each n>1n>1.

Input

The first line of the input contains one integer tt (1≤t≤1001≤t≤100) — the number of test cases. Then tt test cases follow.

The only line of the test case contains one integer nn (2≤n≤1002≤n≤100) — the length of the permutation you have to find.

Output

For each test case, print nn distinct integers p1,p2,…,pnp1,p2,…,pn — a permutation that there is no index ii (1≤i≤n1≤i≤n) such that pi=ipi=i (so, for all ii from 11 to nn the condition pi≠ipi≠i should be satisfied).

If there are several answers, you can print any. It can be proven that the answer exists for each n>1n>1.

Example

input

Copy

2
2
5

output

Copy

2 1
2 1 5 3 4

#include<iostream>
using namespace std;
int main(void)
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        if(n%2==0)
        {
            for(int i=n; i>0;i--)
                cout<<i<<" ";
        }
        else
        {
            for(int i =n-1;i>1;i--)
            {

                cout<<i<<" ";
            }
            cout<<n<<" ";
            if(n!=1){
            cout<<1<<" ";
            }
        }
    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值