#include <bits/stdc++.h>

using namespace std;

#define int ll
typedef long long ll;
typedef long double ld;

void print(vector<int> v) {
  cout << " ---> ";
  for (auto &x : v) {
    cout << x << " ";
  }
  cout << "\n";
}

int over = 0;

vector<int> get(vector<int> a) {
  vector<int> init = a;
  vector<int> sol;
  int n = (int) a.size(), cur = 0;



  while (1) {
    //cout << (int) sol.size() << " and " << cur << " | ";
    //print(a);
    while (1) {
      bool Something = 0;
      for (int i = 0; i + 1 < n; i++) {
        if (i % 2 == cur && a[i] > a[i + 1]) {
          sol.push_back(i);
          swap(a[i], a[i + 1]);
          cur ^= 1;
          Something = 1;
          break;
        }
      }
      if (!Something) break;
    }
    bool ok = 1;

    for (int i = 0; i < n; i++) {
      ok &= (a[i] == i + 1);
    }

    if (ok) break;

    bool Something = 0;
    for (int i = 0; i + 1 < n; i++) {
      if (a[i] > a[i + 1]) {
        if (i + 2 < n) {
          sol.push_back(i + 1);
          swap(a[i + 1], a[i + 2]);
          cur ^= 1;
          Something = 1;
          break;
        }
        if (i - 1 >= 0) {
          sol.push_back(i - 1);
          swap(a[i - 1], a[i]);
          cur ^= 1;
          Something = 1;
          break;
        }
      }
    }
    if (!Something) {
      cout << "bad\n";
      print(a);
    }
    assert(Something);

  }


  bool ok = 1;

  for (int i = 0; i < n; i++) {
    ok &= (a[i] == i + 1);
  }




///  over = max(over, (int) sol.size() - n * n);
  ok &= ((int) sol.size() <= n * n);

  if (!ok) {
    cout << "bad\n";
    cout << "init"; print(init);
    cout << "a"; print(a);
    cout << "sol"; print(sol);

    exit(0);
  }
  assert(ok);

  return sol;
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);

  /**
  for (int len = 1; len <= 10; len++) {
    over = 0;
    vector<int> v(len);
    iota(v.begin(), v.end(), 1);
    auto it = get(v);
    while (next_permutation(v.begin(), v.end())) {
      it = get(v);
    }


    cout << "\t\t\t\t done " << len << " and " << over << "\n";
  }
  return 0;
**/

  int tt;
  cin >> tt;
  while (tt--) {
      int n;
    cin >> n;
    vector<int> a(n);

    for (int i = 0; i < n; i++) cin >> a[i];
    auto it = get(a);
    cout << (int) it.size() << "\n";
    for (auto &val : it) cout << val + 1 << " ";
    cout << "\n";
  }
  return 0;
}


#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define rep(i, n) for(int i=0;i<n;i++)
#define all(i, v) for(auto& i : v)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

ll n;
ll solve(ll m){
    if(m >= n) m -= n;
    else m += n;
    return m;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll q;
    string s;
    cin >> n >> s >> q;
    bool maki = 0;
    ll t, a, b;

    rep(i, q){
        cin >> t >> a >> b;
        a--; b--;

        if(t == 1){
            if(maki) {
                a = solve(a);
                b = solve(b);
            }
            swap(s[a], s[b]);
        }else{
            maki ^= 1;
        }
    }
    if(maki){
        cout << s.substr(n, n);
        cout << s.substr(0, n) << endl;
    }else{
        cout << s << endl;
    }

    return 0;
}


