fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. // Macros for convenience
  5. #define ll long long
  6. #define ull unsigned long long
  7. #define pb push_back
  8. #define pii pair<int, int>
  9. #define pll pair<ll, ll>
  10.  
  11. typedef vector<ll> vl;
  12. typedef pair<ll, ll> pl;
  13.  
  14. // Constants
  15. const int MOD = 1e9 + 7;
  16. const int INF = 1e9;
  17. const ll LINF = 1e18;
  18.  
  19. // Fast input/output
  20. void fast_io()
  21. {
  22. ios_base::sync_with_stdio(false);
  23. cin.tie(NULL);
  24. cout.tie(NULL);
  25. }
  26.  
  27. // Utility functions
  28. template <typename T>
  29. void print_vector(const vector<T> &v)
  30. {
  31. for (const T &x : v)
  32. {
  33. cout << x << " ";
  34. }
  35. cout << "\n";
  36. }
  37.  
  38. ll mod_exp(ll base, ll exp, ll mod = MOD)
  39. {
  40. ll res = 1;
  41. while (exp > 0)
  42. {
  43. if (exp % 2 == 1)
  44. res = (res * base) % mod;
  45. base = (base * base) % mod;
  46. exp /= 2;
  47. }
  48. return res;
  49. }
  50.  
  51. ll gcd(ll a, ll b)
  52. {
  53. while (b)
  54. {
  55. a %= b;
  56. swap(a, b);
  57. }
  58. return a;
  59. }
  60.  
  61. ll lcm(ll a, ll b)
  62. {
  63. return (a / gcd(a, b)) * b;
  64. }
  65.  
  66.  
  67. bool isPrime(ll n) {
  68. // Handle edge cases
  69. if (n <= 1) return false;
  70. if (n <= 3) return true;
  71. if (n % 2 == 0 || n % 3 == 0) return false;
  72.  
  73. // Check for factors from 5 to sqrt(n)
  74. for (ll i = 5; i <= sqrtl(n); i += 6) {
  75. if (n % i == 0 || n % (i + 2) == 0) {
  76. return false;
  77. }
  78. }
  79. return true;
  80. }
  81.  
  82.  
  83. ll modInverse(ll a, ll m) {
  84. return mod_exp(a, m - 2, m);
  85. }
  86.  
  87.  
  88. void GcdOne(ll &p, ll &q) {
  89.  
  90. // If gcd(p, q) == 1, divide both p and q by their gcd
  91. ll g = gcd(p, q);
  92. p /= g;
  93. q /= g;
  94.  
  95. }
  96.  
  97. bool isPalindrome(const string& str) {
  98.  
  99. string cleaned_str;
  100. string reversed_str = cleaned_str;
  101. reverse(reversed_str.begin(), reversed_str.end());
  102.  
  103. return cleaned_str == reversed_str;
  104. }
  105.  
  106.  
  107.  
  108. // Solution function
  109. void solve()
  110. {
  111. int n;
  112. cin>>n;
  113. if(n<=4)cout<<-1<<endl;
  114. else{
  115. for(int i=1;i<=n;i+=2){
  116. if(i!=5){
  117. cout<<i<<" ";
  118. }
  119. }
  120. cout<<5<<" "<<4<<" ";
  121. for(int i=2;i<=n;i+=2){
  122. if(i!=4)cout<<i<<" ";
  123.  
  124. }
  125. cout<<'\n';
  126. }
  127.  
  128. }
  129.  
  130. // Main function
  131. int main()
  132. {
  133. fast_io();
  134.  
  135. int t;
  136. cin >> t;
  137. while (t--)
  138. {
  139.  
  140. solve();
  141. }
  142.  
  143. return 0;
  144. }
  145.  
Success #stdin #stdout 0.01s 5256KB
stdin
2
3
8
stdout
-1
1 3 7 5 4 2 6 8