#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int nax = 1e6 + 10;
vector<int> tree(4 * nax);
long long i, j, x, y, k;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, t;
  cin >> t;
  while (t--) {
    cin >> n;
    vector<long long> a;
    set<long long> b;
    for (i = 0; i < n; i++) {
      cin >> x;
      a.push_back(x);
      b.insert(x);
    }
    if (b.size() == 1) {
      cout << 1 << endl;
      for (i = 0; i < n; i++) cout << 1 << " ";
    } else if (a.size() % 2 == 0) {
      cout << 2 << endl;
      for (i = 0; i < n / 2; i++) cout << 1 << " " << 2 << " ";
    } else if (a.size() % 2 != 0) {
      vector<long long> ans;
      int p = 0, q = 0;
      ans.push_back(1);
      for (i = 1; i < a.size() - 1; i++) {
        if (a[i] == a[i - 1] && p == 0) {
          ans.push_back(ans[i - 1]);
          p = 1;
        } else if (q == 0) {
          ans.push_back(2);
          q = 1;
        } else if (q == 1) {
          ans.push_back(1);
          q = 0;
        }
      }
      if (p == 1) {
        if (q == 1)
          ans.push_back(1);
        else
          ans.push_back(2);
      } else {
        if (a[n - 1] == a[n - 2])
          ans.push_back(ans[n - 2]);
        else if (a[n - 1] == a[0])
          ans.push_back(ans[0]);
        else
          ans.push_back(3);
      }
      if (ans[n - 1] == 3)
        cout << 3 << endl;
      else
        cout << 2 << endl;
      for (i = 0; i < ans.size(); i++) cout << ans[i] << " ";
    }
    cout << endl;
  }
}
