#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  cin >> T;
  for (int test = 1; test <= T; test++) {
    int N;
    cin >> N;
    vector<int> vett(N, 1);
    bool same = true;
    int vicini = -1;
    int prev = 0;
    int first;
    for (int i = 0; i < N; i++) {
      int tmp;
      cin >> tmp;
      if (i == 0) {
        first = tmp;
      }
      if (i == N - 1 && first == tmp) {
        vicini = N - 1;
      }
      if (i != 0 && tmp != prev) {
        same = false;
      }
      if (i != 0 && tmp == prev) {
        vicini = i - 1;
      }
      prev = tmp;
    }
    if (same) {
      cout << "1" << endl;
    } else if (N % 2 == 0) {
      cout << "2" << endl;
      for (int i = 0; i < N; i += 2) {
        vett[i] = 2;
      }
    } else if (vicini != -1) {
      cout << "2" << endl;
      int a = 1;
      int b = 2;
      for (int i = 0; i < N; i++) {
        int att = 1;
        if (i % 2 == 0) {
          att = a;
        } else {
          att = b;
        }
        vett[i] = att;
        if (i == vicini && vicini != N - 1) {
          i++;
          vett[i] = att;
          int tmp = a;
          a = b;
          b = tmp;
        }
      }
    } else {
      cout << "3" << endl;
      for (int i = 0; i < N; i += 2) {
        vett[i] = 2;
      }
      vett[N - 1] = 3;
    }
    for (int i = 0; i < N; i++) {
      cout << vett[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
