#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[ ";
  for (auto v : V) os << v << " ";
  os << "]";
  return os;
}
template <class T>
ostream &operator<<(ostream &os, set<T> S) {
  os << "{ ";
  for (auto s : S) os << s << " ";
  return os << "}";
}
template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
template <class L, class R>
ostream &operator<<(ostream &os, map<L, R> M) {
  os << "{ ";
  for (auto m : M) os << "(" << m.first << ":" << m.second << ") ";
  return os << "}";
}
long long n, a[200005], c[200005], cc[200005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    cin >> n;
    for (long long i = 1; i < n + 1; i++) cin >> a[i];
    for (long long i = 1; i < n + 1; i++) {
      long long k = 1;
      if (c[i - 1] == 1) k = 2;
      long long j = i;
      while (j <= n && a[j] == a[i]) c[j] = k, j++;
      i = j - 1;
    }
    if (c[1] == c[n] && a[1] != a[n]) {
      bool ok = false;
      for (long long i = 1; i < n; i++) {
        if (c[i] == c[i + 1]) {
          for (long long j = i + 1; j < n + 1; j++) {
            if (c[j] == 1)
              c[j] = 2;
            else
              c[j] = 1;
          }
          ok = true;
          break;
        }
      }
      if (!ok) c[n] = 3;
    }
    long long mx = 0;
    for (long long i = 1; i < n + 1; i++) mx = max(mx, c[i]);
    cout << mx << '\n';
    for (long long i = 1; i < n + 1; i++) cout << c[i] << " ";
    cout << '\n';
  }
  return 0;
}
