description: You have a permutation: an array a = [a_1, a_2, …, a_n] of distinct integers from 1 to n. The length of the permutation n is odd.
  
  You need to sort the permutation in increasing order.
  
  In one step, you can choose any prefix of the permutation with an odd length and reverse it. Formally, if a = [a_1, a_2, …, a_n], you can choose any odd integer p between 1 and n, inclusive, and set a to [a_p, a_{p-1}, …, a_1, a_{p+1}, a_{p+2}, …, a_n].
  
  Find a way to sort a using no more than 5n/2 reversals of the above kind, or determine that such a way doesn't exist. The number of reversals doesn't have to be minimized.
  
  Input
  
  Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 100). Description of the test cases follows.
  
  The first line of each test case contains a single integer n (3 ≤ n ≤ 2021; n is odd) — the length of the permutation.
  
  The second line contains n distinct integers a_1, a_2, …, a_n (1 ≤ a_i ≤ n) — the permutation itself. 
  
  It is guaranteed that the sum of n over all test cases does not exceed 2021.
  
  Output
  
  For each test case, if it's impossible to sort the given permutation in at most 5n/2 reversals, print a single integer -1.
  
  Otherwise, print an integer m (0 ≤ m ≤ 5n/2), denoting the number of reversals in your sequence of steps, followed by m integers p_i (1 ≤ p_i ≤ n; p_i is odd), denoting the lengths of the prefixes of a to be reversed, in chronological order.
  
  Note that m doesn't have to be minimized. If there are multiple answers, print any.
  
  Example
  
  Input
  
  
  3
  3
  1 2 3
  5
  3 4 5 2 1
  3
  2 1 3
  
  
  Output
  
  
  4
  3 3 3 3
  2
  3 5
  -1
  
  Note
  
  In the first test case, the permutation is already sorted. Any even number of reversals of the length 3 prefix doesn't change that fact.
  
  In the second test case, after reversing the prefix of length 3 the permutation will change to [5, 4, 3, 2, 1], and then after reversing the prefix of length 5 the permutation will change to [1, 2, 3, 4, 5].
  
  In the third test case, it's impossible to sort the permutation.
solution: import java.io.*;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.StringTokenizer;
  import java.util.List;
   import java.util.*;
   public class realfast implements Runnable 
    {
      private static final int INF = (int) 1e9;
      long in= 1000000007;
      long fac[]= new long[1000001];
      long inv[]=new long[1000001];
      public  void solve() throws IOException 
      {
          int t = readInt();
          for(int f =0;f<t;f++){
          int n = readInt();
  
          int arr[]=new int[n+1];
          for(int i=1;i<=n;i++)
          {
              arr[i]= readInt();
          }
  
          boolean check = true;
          if(n%2==0&&arr[n]!=n)
          {
              check = false;
          }
          for(int i=1;i<=n;i++)
          {
              if((i%2)!=(arr[i]%2))
              {
                  check = false;
              }
          }
          if(!check)
              out.println(-1);
          else
          {
              ArrayList<Integer> ans = new ArrayList<Integer>();
              if(n%2==0)
                  n--;
              for(int i=n;i>=3;i=i-2)
              {
                 int pos = find(arr,i);
                 reverse(arr,pos);
                 ans.add(pos);
  
                 pos = find(arr,i-1);
                 reverse(arr,pos-1);
                 ans.add(pos-1);
  
                 reverse(arr,i);
                 ans.add(i);
                 pos = find(arr,i);
                 reverse(arr,pos);
  
                 ans.add(pos);
  
  
                 reverse(arr,i);
                 ans.add(i);
  
              }
              out.println(ans.size());
              if(ans.size()>0){
              for(int i=0;i<ans.size();i++)
                  out.print((ans.get(i))+" ");
              out.println();
               }
          }
          
         }
  
      }
      public void reverse(int arr[] , int len )
      {
  
          for(int i=1;i<=(len/2);i++)
          {
              int j = len-i+1;
              int temp=arr[i];
              arr[i]= arr[j];
              arr[j]= temp;
          }               
      }
      public int find(int arr[] , int val)
      {
          for(int i=1;i<arr.length;i++)
          {
              if(arr[i]==val)
              {
                  return i;
              }
          }
          return -1;
  
      }
     
      public long query(long seg[] , int left, int right , int index, int l , int r)
      {   
           long inf = 100000000;
           inf = inf*inf;
          if(left>=l&&right<=r)
          {
              return seg[index];
          }
          if(l>right||left>r)
              return inf;
          int mid = left+(right-left)/2;
          return Math.min(query(seg,left,mid,2*index+1,l,r),query(seg,mid+1,right,2*index+2,l,r));
  
      }
      
      public int value (int seg[], int left , int right ,int index, int l, int r)
      {
              
              if(left>right)
              {
                return -100000000;
              }
              if(right<l||left>r)
                  return -100000000;
              if(left>=l&&right<=r)
                  return seg[index];
              int mid = left+(right-left)/2;
              int val = value(seg,left,mid,2*index+1,l,r);
              int val2 = value(seg,mid+1,right,2*index+2,l,r);
              return Math.max(val,val2);
  
      }
     
      public int gcd(int a , int b )
      {
        if(a<b)
        {
          int t =a;
          a=b;
          b=t;
        }
        if(a%b==0)
          return b ;
        return gcd(b,a%b);
      }
      public long pow(long n , long p,long m)
      {
           if(p==0)
              return 1;
          long val = pow(n,p/2,m);;
          val= (val*val)%m;
          if(p%2==0)
              return val;
          else
              return (val*n)%m;
      }
      
      
      ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      public static void main(String[] args) {
          new Thread(null, new realfast(), "", 128 * (1L << 20)).start();
      }
   
      private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
      private BufferedReader reader;
      private StringTokenizer tokenizer;
      private PrintWriter out;
   
      @Override
      public void run() {
          try {
              if (ONLINE_JUDGE || !new File("input.txt").exists()) {
                  reader = new BufferedReader(new InputStreamReader(System.in));
                  out = new PrintWriter(System.out);
              } else {
                  reader = new BufferedReader(new FileReader("input.txt"));
                  out = new PrintWriter("output.txt");
              }
              solve();
          } catch (IOException e) {
              throw new RuntimeException(e);
          } finally {
              try {
                  reader.close();
              } catch (IOException e) {
                  // nothing
              }
              out.close();
          }
      }
   
      private String readString() throws IOException {
          while (tokenizer == null || !tokenizer.hasMoreTokens()) {
              tokenizer = new StringTokenizer(reader.readLine());
          }
          return tokenizer.nextToken();
      }
   
      @SuppressWarnings("unused")
      private int readInt() throws IOException {
          return Integer.parseInt(readString());
      }
   
      @SuppressWarnings("unused")
      private long readLong() throws IOException {
          return Long.parseLong(readString());
      }
   
      @SuppressWarnings("unused")
      private double readDouble() throws IOException {
          return Double.parseDouble(readString());
      }
  }
  class edge implements Comparable<edge>{
      int u ;
      int v;
      
      edge(int  u, int v)
      {
         this.u=u;
         this.v=v;
      }
      public int compareTo(edge e)
      {
          return this.v-e.v;
      }
  }