#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long INF = LLONG_MAX;
const long long NINF = LLONG_MIN;
int main() {
  long long t = 1;
  cin >> t;
  while (t-- > 0) {
    long long n;
    cin >> n;
    set<long long> s;
    long long t[n];
    for (int i = 0; i < n; i++) cin >> t[i];
    long long c[n], j = 1, k = 0, k_i = -1;
    c[0] = 1;
    for (int i = 1; i < n; i++) {
      if (t[i] == t[i - 1]) {
        c[i] = c[i - 1];
        k_i = i;
        k = 1;
      } else {
        c[i] = ((c[i - 1] + 1) % 2 == 0) ? 2 : 1;
        j = 2;
      }
    }
    if (c[0] == c[n - 1] && t[0] != t[n - 1]) {
      if (k == 0) {
        c[n - 1] = 3;
        j = 3;
      } else {
        c[k_i] = ((c[k_i] + 1) % 2 == 0) ? 2 : 1;
        for (int i = k_i + 1; i < n; i++) {
          c[i] = ((c[i - 1] + 1) % 2 == 0) ? 2 : 1;
        }
      }
    }
    cout << j << endl;
    for (int i = 0; i < n; i++) cout << c[i] << ' ';
    cout << endl;
  }
}
