#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int flag = 0;
    int n;
    cin >> n;
    vector<int> v(2 * n);
    for (int i = 0; i < n; i++) {
      cin >> v[i];
      v[n + i] = v[i];
    }
    for (int i = 0; i <= n; i++) {
      if (i == n) {
        flag = 1;
        cout << 1 << '\n';
        for (int j = 0; j < n; j++) cout << 1 << " ";
        cout << '\n';
        break;
      }
      if (v[i] != v[i + 1]) break;
    }
    if (flag) continue;
    if (n % 2 == 0) {
      flag = 1;
      cout << 2 << '\n';
      for (int i = 0; i < n; i++) cout << i % 2 + 1 << " ";
      cout << '\n';
    }
    if (flag) continue;
    for (int i = 0; i < n; i++) {
      if (v[i] == v[i + 1]) {
        flag = 1;
        if (i != n - 1) {
          int swi = 0;
          cout << 2 << '\n';
          for (int j = 0; j < n; j++) {
            cout << (j + swi) % 2 + 1 << " ";
            if (j == i) {
              swi = 1;
            }
          }
          cout << '\n';
        } else {
          cout << 2 << '\n';
          for (int j = 0; j < n; j++) cout << j % 2 + 1 << " ";
          cout << '\n';
        }
        break;
      }
    }
    if (flag) continue;
    cout << 3 << '\n';
    cout << 3 << " ";
    for (int i = 1; i < n; i++) {
      cout << i % 2 + 1 << " ";
    }
    cout << '\n';
  }
}
