#include <bits/stdc++.h>   using namespace std;   const long long N = 2e5 + 5;   const long long inf = 199999999999999999;   const long long mod = 1e9 + 7;   void read() {     freopen( lifeguards.in ,  r , stdin);     freopen( lifeguards.out ,  w , stdout);   }   void solve() {     int coloured[N] = {}, pp[N] = {}, mx = 0, mx1 = 0, attribute = 0, cur = 0;     long long n;     cin >> n;     vector<long long> v(n);     for (auto &i : v) {       cin >> i;       if (i == cur) attribute = 1;       cur = i;     }     if (v[0] == v[n - 1]) attribute = 1;     if (is_sorted(v.begin(), v.end()) && v[0] == v[n - 1]) {       cout <<  1 n ;       for (int i = 0; i < n; ++i) {         cout <<  1  ;       }       return;     }     if (n & 1 ^ 1) {       cout <<  2 n ;       for (int i = 0; i < n; ++i) {         if (i & 1)           cout <<  1  ;         else           cout <<  2  ;       }       return;     } else {       if (attribute) {         cout <<  2 n ;         long long op = 1, borely = 1;         cur = 2;         for (int i = 0; i < n; ++i) {           if (v[i] == v[i - 1] && op) {             if (cur == 2)               cout <<  2  , cur = 2;             else               cout <<  1  , cur = 1;             op ^= 1;             continue;           }           if (cur == 2)             cout <<  1  , cur = 1;           else             cout <<  2  , cur = 2;         }       } else {         cout <<  3 n ;         for (int i = 0; i < n - 1; ++i) {           if (i & 1)             cout <<  1  ;           else             cout <<  2  ;         }         cout << 3;       }     }   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long T = 1;     cin >> T;     while (T--) {       solve();       cout <<   n ;     }     cerr <<   nTime elapsed:  << 1.0 * clock() / CLOCKS_PER_SEC <<   s. n ;   }   