#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n];
    unordered_set<int> s;
    for (long long i = 0; i < n; ++i) {
      cin >> a[i];
      s.insert(a[i]);
    }
    if (s.size() == 1) {
      cout << 1 << endl;
      for (long long i = 0; i < n; i++) {
        cout << 1 << " ";
      }
      cout << endl;
    } else if (n % 2 == 0) {
      cout << 2 << endl;
      int o = 1;
      for (long long i = 0; i < n; i++) {
        cout << o << " ";
        o = 3 - o;
      }
      cout << endl;
    } else {
      int check = 0, pos = 0, o = 1;
      for (long long i = 0; i < n - 1; i++) {
        if (a[i] == a[i + 1]) {
          check = 1;
          pos = i + 1;
          break;
        }
      }
      if (a[n - 1] == a[0]) {
        check = 1;
        pos = n;
      }
      if (check) {
        cout << 2 << endl;
        for (long long i = 0; i < n; i++) {
          if (i == pos) {
            o = 3 - o;
            cout << o << " ";
          } else {
            cout << o << " ";
          }
          o = 3 - o;
        }
        cout << endl;
      } else {
        cout << 3 << endl;
        for (int i = 0; i < n - 1; i++) {
          cout << o << " ";
          o = 3 - o;
        }
        cout << 3 << endl;
      }
    }
  }
  return 0;
}
