#include <bits/stdc++.h>
using namespace std;
int main() {
  int kase;
  cin >> kase;
  while (kase--) {
    int n;
    cin >> n;
    int x = 1;
    int arr[n + 5];
    bool flag = true;
    for (int i = 1; i <= n; i++) {
      cin >> arr[i];
      if (i == 1)
        x = arr[i];
      else if (x != arr[i])
        flag = false;
    }
    if (flag) {
      cout << "1" << '\n';
      for (int i = 1; i <= n; i++) cout << "1 ";
      cout << '\n';
    } else if (n % 2 == 0) {
      cout << "2" << '\n';
      for (int i = 1; i <= n; i++) {
        if (i % 2)
          cout << "1 ";
        else
          cout << "2 ";
      }
      cout << '\n';
    } else {
      int in = 1;
      string s;
      int cnt = 1;
      vector<int> vec;
      vec.clear();
      int mx = 1;
      flag = false;
      while (in <= n) {
        if (in < n && arr[in] == arr[in + 1] && !flag)
          flag = true, vec.push_back(cnt), vec.push_back(cnt), in = in + 2;
        else
          vec.push_back(cnt), in++;
        cnt++;
        if (cnt == 3) cnt = 1;
      }
      if (vec[0] == vec[n - 1] && arr[1] != arr[n])
        vec[n - 1] = 3, mx = 3;
      else
        mx = 2;
      cout << mx << '\n';
      for (int i = 0; i < (int)vec.size(); i++) cout << vec[i] << " ";
      cout << '\n';
    }
  }
  return 0;
}
