#include <bits/stdc++.h>
using namespace std;
const int SIGMA = 512;
const int MAX = 200010;
const int MAXT = 1200010;
const long long INF = 1000000000000000100;
const long long P = 1000000007;
const double EPS = 1e-6;
const double PI = 3.14159265358979;
bool allEqual(vector<int> &v) {
  for (int i = 1; i < ((int)v.size()); i++) {
    if (v[i] != v[i - 1]) {
      return false;
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> type(n);
    for (int i = 0; i < n; i++) {
      cin >> type[i];
    }
    int total = 0;
    vector<int> color;
    if (allEqual(type)) {
      total = 1;
      color = vector<int>(n, 1);
    } else if (n & 1) {
      int beg = -1, end = -1;
      for (int i = 0; i < n; i++) {
        int next = i == n - 1 ? 0 : i + 1;
        if (type[i] == type[next]) {
          beg = next;
          end = i;
          break;
        }
      }
      if (beg != -1 && end != -1) {
        total = 2;
        int c = 2;
        color = vector<int>(n, 0);
        color[beg] = color[end] = 1;
        for (int i = beg == n - 1 ? 0 : beg + 1; i != end; i = (i + 1) % n) {
          color[i] = c;
          if (c == 2)
            c = 1;
          else
            c = 2;
        }
      } else {
        total = 3;
        color = vector<int>(n, 2);
        for (int i = 0; i < n; i++) {
          if (i & 1) color[i] = 1;
        }
        color[n - 1] = 3;
      }
    } else {
      total = 2;
      color = vector<int>(n, 2);
      for (int i = 0; i < n; i++) {
        if (i & 1) color[i] = 1;
      }
    }
    cout << total << endl;
    for (int i = 0; i < ((int)color.size()); i++) {
      cout << color[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
