#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, n, q;
  cin >> t;
  while (t--) {
    cin >> n;
    vector<long long int> x(n, 0);
    vector<long long int> y(n, 0);
    ;
    for (long long int i = 0; i < n; i++) cin >> x[i];
    ;
    int f = 1, in = 0;
    y[0] = 1;
    int a = 1;
    for (long long int i = 1; i < n; i++) {
      if (x[i] == x[i - 1]) {
        y[i] = y[i - 1];
        in = i;
      } else {
        f = 2;
        if (y[i - 1] == 1) {
          y[i] = 2;
        } else {
          y[i] = 1;
        }
      }
    }
    if (x[n - 1] != x[0]) {
      if (y[n - 1] == y[0]) {
        if (in == 0) {
          f = 3;
          y[n - 1] = 3;
        } else {
          for (long long int i = in; i < n; i++) {
            if (y[i] == 1) {
              y[i] = 2;
            } else {
              y[i] = 1;
            }
          }
        }
      }
    }
    cout << f << endl;
    ;
    for (long long int i = 0; i < n; i++) cout << y[i] << " ";
    ;
    cout << endl;
  }
}
