#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll min(ll a, ll b) {
  if (a < b) return a;
  return b;
}
void solve() {
  ll testCases;
  cin >> testCases;
  while (testCases--) {
    ll n;
    cin >> n;
    vector<ll> arr(n);
    vector<ll> res(n, 1);
    for (int i = 0; i < n; i++) cin >> arr[i];
    int i = 0;
    for (i = 0; i < n; i++) {
      if (arr[i] != arr[(i + 1) % n]) break;
    }
    if (i == n) {
      cout << "1\n";
      for (i = 0; i < n; i++) cout << 1 << " ";
      cout << "\n";
      continue;
    }
    if (n % 2 == 0) {
      cout << "2\n";
      for (i = 0; i < n; i++) cout << (i % 2) + 1 << " ";
      cout << "\n";
      continue;
    } else {
      bool isTwo = 0;
      for (i = 0; i < n; i++) {
        if (arr[i] == arr[(i + 1) % n]) {
          for (int j = 0, k = i + 1; k < n; k++, j ^= 1) res[k] = j + 1;
          for (int j = 0, k = i; k >= 0; k--, j ^= 1) res[k] = j + 1;
          cout << "2\n";
          for (auto e : res) cout << e << " ";
          cout << "\n";
          isTwo = 1;
          break;
        }
      }
      if (!isTwo) {
        cout << "3\n";
        for (i = 0; i < n - 1; i++) cout << i % 2 + 1 << " ";
        cout << "3\n";
      }
    }
  }
}
int main() {
  {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  };
  solve();
  return 0;
}
