#include <bits/stdc++.h>
using namespace std;
const long long N = 2e6 + 6;
const long long M = 1e9 + 7;
vector<long long> A;
vector<long long> B;
long long n;
void solve() {
  cin >> n;
  A.resize(n);
  B.resize(n);
  map<long long, long long> mmp;
  for (long long i = 0; i < n; i++) {
    cin >> A[i];
    mmp[A[i]] = 1;
  }
  bool flag = 0;
  long long ans = 0;
  if (mmp.size() == 1) {
    cout << 1 << "\n";
    for (long long i = 0; i < n; i++) {
      cout << 1 << " ";
    }
  } else if (n % 2 == 0) {
    cout << 2 << "\n";
    for (long long i = 0; i < n; i++) {
      if (i % 2 == 0)
        cout << 1 << " ";
      else
        cout << 2 << " ";
    }
  } else if (n % 2) {
    B[0] = 1;
    for (long long i = 1; i < n; i++) {
      if (flag) {
        B[i] = 3 - B[i - 1];
        continue;
      }
      if (A[i] == A[i - 1]) {
        flag = 1;
        B[i] = B[i - 1];
      } else if (A[i] != A[i - 1]) {
        B[i] = 3 - B[i - 1];
      }
    }
    if (!flag) {
      if (A[0] == A[n - 1]) {
        cout << 2 << "\n";
      } else {
        cout << 3 << "\n";
        B[n - 1] = 3;
      }
    } else {
      cout << 2 << "\n";
    }
    for (long long i = 0; i < n; i++) cout << B[i] << " ";
  }
  cout << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) solve();
}
