#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while(T--) {
    int N;
    cin >> N;
    vector<string> S(3);
    REP(i, 3) cin >> S[i];
    bool zerozero = false;
    bool zeroone = false;
    bool onezero = false;
    bool oneone = false;
    int idx = 0;
    REP(i, 3) {
      if(S[i][0] == '0') {
        if(S[i][S[i].size()-1] == '0') {
          zerozero = true;
          idx = i;
        } else zeroone = true;
      } else {
        if(S[i][S[i].size()-1] == '0') onezero = true;
        else oneone = true;
      }
    }
    string ans = "";
    if(!zerozero) {
      REP(i, N) ans += '0';
      ans += '1';
      REP(i, N) ans += '0';
    } else if(!oneone){
      REP(i, N) ans += '1';
      ans += '0';
      REP(i, N) ans += '1';
    } else if(!onezero) {
      ans += '0';
      REP(i, N) ans += '1';
      REP(i, N) ans += '0';
    } else {
      ans += '1';
      REP(i, N) ans += '0';
      REP(i, N) ans += '1';
    }
    cout << ans << "\n";
  }
}
#include<bits/stdc++.h>
using namespace std;
int cnt = 0;
struct tree {
	int n;
	vector<vector<int>> g;
	vector<int> vis;
	tree(int n) : n(n) {g = vector<vector<int>>(n); vis = vector<int>(n, 0);}

	void dfs(int root = 0) {
		cnt++;
		vis[root] = 1;
		for (auto i : g[root]) {
			if (!vis[i]) dfs(i);
		}
	}
};

int main() {

	ios::sync_with_stdio(false);
	cin.tie(nullptr);

#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.in", "w", stdout);
#endif


	tree t(200000);
	int n; cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i]; --a[i];
	}

	set<pair<int, int>> s;
	for (int i = 0; i < n / 2; i++) {
		if (a[i] != a[n - i - 1]) {
			int x = a[i], y = a[n - i - 1]; if (x > y)swap(x, y);
			if (s.find({x, y}) == s.end()) {
				t.g[x].push_back(y);
				t.g[y].push_back(x);
				s.insert({x, y});
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < 200000; i++) {
		if (!t.vis[i]) {
			cnt = 0;
			t.dfs(i);
			ans += cnt - 1;
		}
	}

	cout << ans << "\n";



	return 0;
}