#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long maxn = 2e5 + 9;
long long next(long long k) {
  if (k == 1) return 2;
  return 1;
}
void test_case(long long tc) {
  long long n;
  cin >> n;
  map<long long, long long> mp;
  long long arr[n];
  for (long long i = 0; i <= n - 1; ++i) cin >> arr[i], mp[arr[i]]++;
  if (mp.size() == 1) {
    cout << 1 << "\n";
    for (long long i = 0; i <= n - 1; ++i) cout << 1 << " \n"[i == n - 1];
    return;
  }
  if (n % 2 == 0 || arr[0] == arr[n - 1]) {
    cout << 2 << "\n";
    for (long long i = 0; i <= n - 1; ++i)
      cout << (((i % 2) + 1)) << " \n"[i == n - 1];
    return;
  }
  long long ans[n];
  bool ok = true;
  ans[0] = 1;
  long long t = 1;
  for (long long i = 1; i <= n - 1; ++i) {
    if (arr[i] == arr[i - 1] && ok) {
      ok = false;
      ans[i] = t;
      continue;
    }
    t = next(t);
    ans[i] = t;
  }
  if (ok) {
    cout << "3\n";
    for (long long i = 0; i <= n - 2; ++i) cout << (((i % 2) + 1)) << " ";
    cout << 3 << " \n";
    return;
  }
  cout << 2 << "\n";
  for (long long i = 0; i <= n - 1; ++i) cout << ans[i] << " ";
  cout << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long t = 1;
  cin >> t;
  for (long long tc = 1; tc <= t; ++tc) test_case(tc);
}
