Card Rotation
Submissions: 1537   Accuracy:

63.48%

  Difficulty: Medium   Marks: 4

Given a sorted deck of cards numbered 1 to N.

1) We pick up 1 card and put it on the back of the deck.

2) Now, we pick up another card , it turns out to be card numbered 1 , we put it outside the deck.

3) Now we pick up 2 cards and put it on the back of the deck.

4) Now, we pick up another card and it turns out to be card numbered 2 , we put it outside the deck. ...

We perform this step till the last card.

If such arrangement of decks is possible, output the arrangement, if it is not possible for a particular value of N then output -1.

Input:

The first line of the input contains the number of test cases 'T', after that 'T' test cases follow. 
Each line of the test case consists of a single linecontaining an integer 'N'.


Output:

If such arrangement of decks is possible, output the arrangement, if it is not possible for a particular value of n then output -1.

Constraints:

1 <= T <= 100;
1<= N<= 1000; 

 

Example:

Input :

2
4
5

Output :

2 1 4 3
3 1 4 5 2

** For More Input/Output Examples Use 'Expected Output' option **

Author: jain_rishabh


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.