#include <bits/stdc++.h>
using namespace std;
const int mode = 998244353;
const int Nmax = 1e6 + 2;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t, n;
  cin >> t;
  string a, b, x;
  while (t--) {
    int cnt = 0;
    cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; ++i) cin >> arr[i];
    int st = 0;
    for (int i = 0; i < n; ++i)
      if (arr[i] != arr[(i + 1) % n])
        cnt++;
      else
        st = i + 1;
    if (cnt == 0) {
      cout << "1\n";
      for (int i = 0; i < n; ++i) cout << "1 ";
    } else if (cnt == n && (n & 1)) {
      cout << "3\n";
      cout << "1 ";
      for (int i = 1; i < n; ++i) {
        if (i & 1)
          cout << "2 ";
        else
          cout << "3 ";
      }
    } else {
      cout << "2\n";
      for (int i = 0, x = (n - st) & 1; i < n; ++i) {
        if (i == st) x = 0;
        cout << x + 1 << ' ';
        if (arr[i] != arr[(i + 1) % n]) x ^= 1;
      }
    }
    cout << '\n';
  }
  return 0;
}
