#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int p[500];

int main() {
    int t, i;
    
    scanf("%d", &t);
    
    for (i = 0; i < t; i++) {
        int n, c = 1, j, k;
        vector<int> v;
        
        scanf("%d", &n);
        
        for (j = 0; j < n; j++) scanf("%d", &p[j]);
        
        for (j = 1; j <= n; j++) {
            int x;
            
            for (k = 0; k < n; k++) {
                if (p[k] == j) {
                    x = k;
                    break;
                }
            }
            
            if (x == j - 1) continue;
            
            if (x % 2 != c % 2) {
                if (j == n - 1) {
                    v.push_back(n - 3);
                    v.push_back(n - 2);
                    v.push_back(n - 3);
                    v.push_back(n - 2);
                    v.push_back(n - 3);
                    
                    break;
                } else if (x - 2 >= j - 1) {
                    v.push_back(x - 2);
                    swap(p[x - 2], p[x - 1]);
                    c++;
                } else {
                    v.push_back(x);
                    v.push_back(x - 1);
                    swap(p[x], p[x + 1]);
                    swap(p[x - 1], p[x]);
                    x++;
                }
            }
            
            while (x > j - 1) {
                v.push_back(x - 1);
                swap(p[x - 1], p[x]);
                c++;
                x--;
            }
        }
        
        printf("%d\n", v.size());
        for (j = 0; j < v.size(); j++) {
            if (j > 0) putchar(' ');
            printf("%d", v[j] + 1);
        }
        puts("");
    }
    
    return 0;
}

#include<bits/stdc++.h>

using namespace std;

/**************************************************/
#define int long long
#define fr(i,st,c)          for(int i=st;i<c;i++)
#define rfr(i,e,c)          for(int i=e;i>=c;i--) 
#define i_output(f1)        cout<<(f1?"YES":"NO")<<endl;
#define vi                  vector<int>
#define pb                  push_back
#define print(n)            cout<<n<<endl
#define thor                ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define N                   1e9+7


int gcd(int a,int b){
    if(b==0)
        return a;
    return gcd(b,a%b);
}


/***************************************************/





signed main(){

    thor
    
    int h,w,x,y;
    cin>>h>>w>>x>>y;

    vector<string> s(h);

    fr(i,0,h){
        cin>>s[i];
    }

    int sum=0;

    x--,y--;

    
    fr(i,x,h){
        if(s[i][y]=='.'){
            sum++;
        }
        else{
            break;
        }
    }

    rfr(i,x,0){
        if(s[i][y]=='.'){
            sum++;
        }
        else{
            break;
        }
    }
    sum--;
    fr(i,y,w){
        if(s[x][i]=='.'){
            sum++;
        }
        else{
            break;
        }
    }
    sum--;
    rfr(i,y,0){
        if(s[x][i]=='.'){
            sum++;
        }
        else{
            break;
        }
    }
    sum--;



    print(sum);




    return 0;
}

