#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
const long long int MOD = 1e9 + 7;
const long long int MOD1 = 998244353;
const long long int N = 2e5 + 5;
const long long int INF = 1000111000111000111LL;
const long double PI = 3.1415926535898;
int32_t main() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int T;
  cin >> T;
  while (T--) {
    long long int n;
    cin >> n;
    vector<long long int> v(n), c(n);
    set<long long int> st;
    for (auto &it : v) {
      cin >> it;
      st.insert(it);
    }
    if ((long long int)((st).size()) == 1) {
      cout << "1\n";
      for (long long int i = (0); i < (n); i++) cout << "1 ";
      cout << '\n';
      continue;
    }
    if ((n + 1) % 2) {
      cout << "2\n";
      for (long long int i = (0); i < (n); i++) {
        if (i % 2)
          cout << "2 ";
        else
          cout << "1 ";
      }
      cout << '\n';
      continue;
    }
    c[0] = 1;
    bool done = false;
    for (long long int i = 1; i < n; i++) {
      if (v[i] == v[i - 1] && !done) {
        c[i] = c[i - 1];
        done = true;
        continue;
      }
      c[i] = 3 - c[i - 1];
    }
    if (!done && v[0] != v[n - 1]) {
      cout << "3\n";
      c[n - 1] = 3;
    } else
      cout << "2\n";
    for (auto it : c) cout << it << ' ';
    cout << '\n';
  }
  return 0;
}
