#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  if ((*max_element(a, a + n)) == (*min_element(a, a + n))) {
    cout << "1\n";
    for (int i = 0; i < n; i++) cout << "1 ";
    cout << '\n';
    return;
  }
  if ((n % 2 == 0) || a[n - 1] == a[0]) {
    cout << "2\n";
    for (int i = 0; i < n; i++) cout << (i % 2) + 1 << " ";
    cout << '\n';
    return;
  }
  int flag = 0;
  for (int i = 1; i < n + 1; i++) {
    if (a[i] == a[i - 1]) flag = i;
  }
  if (flag > 0) {
    cout << "2\n";
    for (int i = 0; i < flag; i++) cout << (i % 2) + 1 << " ";
    cout << (flag - 1) % 2 + 1 << " ";
    for (int i = flag + 1; i < n; i++) {
      if (i % 2)
        cout << "1 ";
      else
        cout << "2 ";
    }
    cout << '\n';
  } else {
    cout << "3\n";
    for (int i = 0; i < n - 1; i++) cout << (i % 2) + 1 << " ";
    cout << "3\n";
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
