#include <bits/stdc++.h>
using namespace std;
int main() {
  int tc;
  cin >> tc;
  while (tc--) {
    int n;
    cin >> n;
    vector<int> v(n);
    int x = 0;
    bool ok = false;
    for (int i = 0; i < n; i++) {
      cin >> v[i];
      if (v[i] == v[0]) x++;
      if ((i > 0 && v[i] == v[i - 1]) || v[0] == v[n - 1]) ok = true;
    }
    if (x == n) {
      cout << 1 << endl;
      for (int i = 0; i < n; i++) cout << 1 << ' ';
      cout << endl;
    } else if (n % 2 == 0) {
      cout << 2 << endl;
      for (int i = 0; i < n; i++) cout << 1 + i % 2 << ' ';
      cout << endl;
    } else {
      if (ok) {
        vector<int> color(n);
        bool ok1 = false;
        cout << 2 << endl << 1 << ' ';
        color[0] = 1;
        for (int i = 1; i < n; i++) {
          if (!ok1 && v[i] == v[i - 1]) {
            ok1 = true;
            color[i] = color[i - 1];
          } else
            color[i] = 1 + color[i - 1] % 2;
          cout << color[i] << ' ';
        }
        cout << endl;
      } else {
        cout << 3 << endl;
        for (int i = 0; i < n - 1; i++) cout << 1 + i % 2 << ' ';
        cout << 3 << endl;
      }
    }
  }
}
