#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<long long>;
using vpi = vector<pair<long long, long long>>;
using vvi = vector<vi>;
using pi = pair<long long, long long>;
const long long nax = 1e5 + 7;
const long long mod = 1e9 + 7;
const long long inf = numeric_limits<long long>::max() - (long long)9e6;
void test() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
  }
  if (count(a.begin(), a.end(), a[0]) == n) {
    cout << 1 << '\n';
    for (long long i = 0; i < n; ++i) {
      cout << 1 << " ";
    }
    cout << '\n';
    return;
  }
  if (n % 2 == 0) {
    cout << 2 << '\n';
    for (long long i = 0; i < n; ++i) {
      cout << i % 2 + 1 << " ";
    }
    cout << '\n';
    return;
  }
  for (long long i = 0; i < n; ++i) {
    if (a[i] == a[(i + 1) % n]) {
      vector<long long> ans(n);
      for (long long j = 0, pos = i + 1; pos < n; ++pos, j ^= 1) {
        ans[pos] = j + 1;
      }
      for (long long j = 0, pos = i; pos >= 0; --pos, j ^= 1) {
        ans[pos] = j + 1;
      }
      cout << 2 << '\n';
      for (long long pos = 0; pos < n; ++pos) {
        cout << ans[pos] << " ";
      }
      cout << '\n';
      return;
    }
  }
  cout << 3 << '\n';
  for (long long i = 0; i < n - 1; ++i) {
    cout << i % 2 + 1 << " ";
  }
  cout << 3 << '\n';
}
signed main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  long long T = 1;
  cin >> T;
  while (T--) {
    test();
  }
  return 0;
}
