#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  long long a[n], i, cnt = 0;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < n; i++)
    if (a[i] == a[(i + 1) % n]) cnt++;
  if (cnt == n) {
    cout << 1 << "\n";
    for (i = 0; i < n; i++) cout << "1 ";
    cout << "\n";
    return;
  }
  if (n % 2) {
    if (cnt == 0) {
      cout << 3 << "\n";
      for (i = 0; i < n - 1; i++)
        if (i % 2)
          cout << "1 ";
        else
          cout << "2 ";
      cout << 3 << "\n";
      return;
    } else {
      cout << 2 << "\n";
      long long z = 1, x = 1;
      for (i = 0; i < n; i++) {
        if (a[i] == a[(i + 1) % n] && x)
          cout << z << " ", x = 0;
        else
          cout << z << " ", z = 3 - z;
      }
      cout << "\n";
      return;
    }
  } else {
    cout << 2 << "\n";
    for (i = 0; i < n; i++)
      if (i % 2)
        cout << "1 ";
      else
        cout << "2 ";
    cout << "\n";
    return;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
