#include <bits/stdc++.h>
void fast() {
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.tie(0);
}
int arr[211111];
int ans[211111];
std::set<int> st;
int main() {
  int t = 1;
  std::cin >> t;
  int n;
  while (t--) {
    st.clear();
    std::cin >> n;
    for (int i = 0; i < n; i++) {
      std::cin >> arr[i];
      st.insert(arr[i]);
    }
    int diffVal = st.size();
    if (diffVal == 1) {
      std::cout << "1\n";
      for (int i = 0; i < n; i++) std::cout << "1 ";
      std::cout << "\n";
    } else if (n % 2 == 0) {
      std::cout << "2\n";
      for (int i = 0; i < n; i++) std::cout << ((i & 1) ? "1 " : "2 ");
      std::cout << "\n";
    } else {
      for (int i = 0; i < n; i++) ans[i] = (i & 1) + 1;
      bool twoAdjSame = 0;
      for (int i = 0; i < n; i++) {
        if (arr[i] == arr[(i + 1) % n]) {
          bool tr = 0;
          for (int ii = (i + 1); ii < n; ii++) {
            ans[ii] = tr + 1;
            tr = !tr;
          }
          tr = 0;
          for (int ii = i; ii >= 0; ii--) {
            ans[ii] = tr + 1;
            tr = !tr;
          }
          std::cout << "2\n";
          for (int ii = 0; ii < n; ii++) {
            std::cout << ans[ii] << " ";
          }
          std::cout << "\n";
          twoAdjSame = 1;
          break;
        }
      }
      if (!twoAdjSame) {
        std::cout << "3\n";
        for (int i = 0; i < n - 1; i++) {
          std::cout << ans[i] << " ";
        }
        std::cout << "3\n";
      }
    }
  }
}
