#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> arr(n, 0);
  for (auto &item : arr) cin >> item;
  if (count(arr.begin(), arr.end(), arr[0]) == n) {
    cout << 1 << endl;
    for (int i = 0; i < n; i++) {
      cout << 1 << " ";
    }
    cout << endl;
    return;
  }
  if (n % 2 == 0) {
    cout << 2 << endl;
    for (int i = 0; i < n; i++) {
      cout << i % 2 + 1 << " ";
    }
    cout << endl;
    return;
  }
  for (int i = 0; i < n; i++) {
    if (arr[i] == arr[(i + 1) % n]) {
      vector<int> ans(n);
      for (int j = 0, pos = i + 1; pos < n; pos++, j ^= 1) {
        ans[pos] = j + 1;
      }
      for (int j = 0, pos = i; pos >= 0; pos--, j ^= 1) {
        ans[pos] = j + 1;
      }
      cout << 2 << endl;
      for (int pos = 0; pos < n; pos++) {
        cout << ans[pos] << " ";
      }
      cout << endl;
      return;
    }
  }
  cout << 3 << endl;
  for (int i = 0; i < n - 1; i++) {
    cout << i % 2 + 1 << " ";
  }
  cout << 3 << endl;
  return;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
