#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    vector<int> t(n);
    for (int i = 0; i < n; i++) cin >> t[i];
    bool ok = true;
    for (int i = 0; i < n - 1; i++)
      if (t[i] != t[i + 1]) ok = false;
    if (ok) {
      cout << 1 << "\n";
      for (int i = 0; i < n; i++) cout << 1 << " ";
      cout << "\n";
      continue;
    }
    if (n % 2 == 0) {
      cout << 2 << "\n";
      for (int i = 0; i < n; i++) cout << (i % 2) + 1 << " ";
      cout << "\n";
      continue;
    }
    ok = false;
    int memo;
    for (int i = 0; i < n - 1; i++)
      if (t[i] == t[i + 1]) ok = true, memo = i;
    if (t[0] == t[n - 1]) ok = true, memo = n - 1;
    if (ok) {
      cout << 2 << "\n";
      if (memo == n - 1) {
        cout << 2 << " ";
        for (int i = 0; i < n - 2; i++) cout << (i % 2) + 1 << " ";
        cout << 2 << " ";
        cout << "\n";
      } else {
        int d = 0;
        for (int i = 0; i < n; i++) {
          if (i == memo) {
            cout << (i % 2) + 1 << " " << (i % 2) + 1 << " ";
            d = 1;
            i++;
          } else
            cout << ((i + d) % 2) + 1 << " ";
        }
        cout << "\n";
      }
      continue;
    }
    cout << 3 << "\n";
    for (int i = 0; i < n - 1; i++) cout << (i % 2) + 1 << " ";
    cout << 3 << "\n";
  }
  return 0;
}
