#include <bits/stdc++.h>
using namespace std;
ifstream fin;
void solve() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  int flag = 0;
  for (int i = 1; i < n; i++) {
    if (arr[i] != arr[i - 1]) {
      flag = 1;
      break;
    }
  }
  if (flag == 0) {
    cout << 1 << endl;
    for (int i = 0; i < n; i++) cout << 1 << ' ';
    cout << endl;
    return;
  }
  if (n % 2 == 0) {
    cout << 2 << endl;
    for (int i = 0; i < n; i++) cout << i % 2 + 1 << ' ';
    cout << endl;
    return;
  }
  flag = 0;
  int l;
  for (int i = 1; i < n; i++) {
    if (arr[i] == arr[i - 1]) {
      flag = 1;
      l = i;
      break;
    }
  }
  if (arr[0] == arr[n - 1]) {
    flag = 1;
    l = 0;
  }
  if (flag == 0) {
    cout << 3 << endl;
    for (int i = 0; i < n - 1; i++) cout << i % 2 + 1 << ' ';
    cout << 3 << endl;
    return;
  }
  cout << 2 << endl;
  if (l == 0) {
    for (int i = 0; i < n; i++) cout << i % 2 + 1 << ' ';
    cout << endl;
  } else {
    int ans[n];
    ans[l] = 1;
    ans[l - 1] = 1;
    for (int i = l - 2; i >= 0; i--) {
      ans[i] = (l - 1 - i) % 2 + 1;
    }
    for (int i = l + 1; i < n; i++) ans[i] = (i - l) % 2 + 1;
    for (int i = 0; i < n; i++) cout << ans[i] << ' ';
    cout << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) solve();
}
