#include <bits/stdc++.h>
using namespace std;
const int NN = 1e6 + 7;
const int N = 2e5 + 7;
const int M = 20;
const long long mod = 998244353;
const long long inf = 1e18 + 7;
const double long rf = 1e-14;
void solve1() {
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> ans(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  int st = 0;
  for (int i = 1; i < n; i++) {
    if (v[i] == v[i - 1]) {
      st = i;
    }
  }
  vector<int> g = {1, 2, 3};
  for (int j = 0; j < n; j++) {
    int i = (st + j) % n;
    vector<int> ch;
    if (v[i] != v[(i - 1 + n) % n]) ch.push_back(ans[(i - 1 + n) % n]);
    if (v[i] != v[(i + 1) % n]) ch.push_back(ans[(i + 1) % n]);
    for (auto x : g) {
      bool f = false;
      for (auto y : ch) {
        if (x == y) f = true;
      }
      if (!f) {
        ans[i] = x;
        break;
      }
    }
  }
  cout << *max_element(ans.begin(), ans.end()) << "\n";
  for (auto x : ans) {
    cout << x << " ";
  }
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  srand(time(0));
  int cghf = 1;
  cin >> cghf;
  while (cghf--) {
    solve1();
  }
}
