#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T, cs = 0;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    if (count(a.begin(), a.end(), a[0]) == n) {
      cout << 1 << '\n';
      for (int i = 0; i < n; i++) {
        cout << 1 << " ";
      }
      cout << '\n';
      continue;
    }
    if (n % 2 == 0) {
      cout << 2 << '\n';
      for (int i = 0; i < n; i++) {
        cout << (i % 2) + 1 << ' ';
      }
      cout << '\n';
      continue;
    }
    bool ok = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] == a[(i + 1) % n]) {
        ok = 1;
        cout << 2 << '\n';
        int cur = 1;
        for (int j = 0; j < n; j++) {
          cout << cur << " ";
          if (j != i) cur = 3 - cur;
        }
        cout << '\n';
        break;
      }
    }
    if (ok) continue;
    cout << 3 << '\n';
    for (int i = 0; i < n - 1; i++) {
      cout << (i % 2) + 1 << ' ';
    }
    cout << 3 << '\n';
  }
  return 0;
}
