#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 1e5 + 10;
int n;
int g[N], f[N];
int main() {
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> g[i];
    f[1] = 1;
    bool st1 = false, st2 = false;
    int flag = 0;
    for (int i = 2; i <= n; i++) {
      if (g[i] != g[i - 1]) {
        st1 = true;
        if (f[i - 1] == 1)
          f[i] = 2;
        else
          f[i] = 1;
      }
      if (g[i] == g[i - 1]) {
        st2 = true;
        flag = i;
        f[i] = f[i - 1];
      }
    }
    int ans = 1;
    if (st1) ans = 2;
    if (g[n] != g[1] && f[n] == f[1]) {
      if (!st2)
        ans = 3, f[n] = 3;
      else {
        if (f[flag] == 1)
          f[flag] = 2;
        else
          f[flag] = 1;
        for (int i = flag + 1; i <= n; i++) {
          if (f[i - 1] == 1)
            f[i] = 2;
          else
            f[i] = 1;
        }
      }
    }
    cout << ans << endl;
    for (int i = 1; i <= n; i++) cout << f[i] << ' ';
    cout << endl;
  }
}
