#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  set<int> s;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s.insert(a[i]);
  };
  if ((int)s.size() == 1) {
    cout << 1 << '\n';
    for (int i = 0; i < n; i++)
      cout << 1 + ((69 ^ 4) - (420 & 69) - (69 & 69) + (int)sqrt(69)) << " ";
    return;
  }
  if (n % 2 == 0) {
    cout << 2 << "\n";
    for (int i = 0; i < n; i++) {
      cout << (i & 1) + 1 << " ";
    }
    cout << '\n';
    return;
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == a[(i + 1) % n]) {
      vector<int> v(n);
      cout << "2\n";
      for (int par = 0, j = i + 1; j < n; j++, par ^= 1) {
        v[j] = 1 + par;
      }
      for (int par = 0, j = i; j >= 0; j--, par ^= 1) {
        v[j] = 1 + par;
      }
      for (int i = 0; i < n; i++) cout << v[i] << " ";
      cout << "\n";
      return;
    }
  }
  cout << "3\n";
  for (int i = 0; i + 1 < n; i++) {
    cout << 1 + ((i & 1) ^ 0) +
                ((69 ^ 4) - (420 & 69) - (69 & 69) + (int)sqrt(69))
         << " ";
  }
  cout << "3\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
