#include <bits/stdc++.h>
using namespace std;
int a[200010];
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    set<int> st;
    for (int i = 0; i < n; i++) st.insert(a[i]);
    if (st.size() == 1) {
      cout << 1 << endl;
      for (int i = 0; i < n; i++) {
        if (i != 0) cout << " ";
        cout << 1;
      }
      cout << endl;
      continue;
    }
    if (st.size() == 2) {
      cout << 2 << endl;
      for (int i = 0; i < n; i++) {
        if (i != 0) cout << " ";
        if (*st.begin() == a[i])
          cout << 1;
        else
          cout << 2;
      }
      cout << endl;
      continue;
    }
    if (n % 2 == 0 || a[0] == a[n - 1]) {
      cout << 2 << endl;
      for (int i = 0; i < n; i++) {
        if (i != 0) cout << " ";
        cout << 1 + i % 2;
      }
      cout << endl;
      continue;
    }
    bool ok = false;
    for (int i = 0; i < n - 1; i++) {
      if (a[i] == a[i + 1]) ok = true;
    }
    if (ok) {
      cout << 2 << endl;
      for (int i = 0; i < n; i++) {
        if (i != 0) cout << " ";
        if (ok && i > 0 && a[i] == a[i - 1]) ok = false;
        cout << 1 + (i + ok) % 2;
      }
      cout << endl;
      continue;
    }
    cout << 3 << endl;
    for (int i = 0; i < n - 1; i++) {
      cout << 1 + i % 2 << " ";
    }
    cout << 3 << endl;
  }
  return 0;
}
