#include <bits/stdc++.h>
using namespace std;
vector<long long> v, c;
long long aux, t, n, pos_space;
bool same, space;
int main() {
  cin >> t;
  for (int j = 0; j < t; j++) {
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> aux;
      v.push_back(aux);
    }
    v.push_back(v[0]);
    same = true;
    space = false;
    pos_space = -1;
    for (int i = 0; i < n; i++) {
      if (v[i] != v[i + 1]) {
        same = false;
      }
      if (v[i] == v[i + 1]) {
        space = true;
        pos_space = i + 1 % n;
      }
    }
    if (same == true) {
      cout << 1 << endl;
      for (int i = 0; i < n; i++) {
        cout << 1 << " ";
      }
      cout << endl;
    }
    if (same == false && space == true) {
      if (n % 2 == 1) {
        cout << 2 << endl;
        int last = 1;
        for (int i = pos_space; i < n + pos_space; i++) {
          c.push_back(last);
          if (last == 1) {
            last = 2;
          } else {
            last = 1;
          }
        }
        for (int i = 0; i < n; i++) {
          cout << c[(n - pos_space + i) % n] << " ";
        }
        cout << endl;
      } else {
        cout << 2 << endl;
        int last = 1;
        for (int i = 0; i < n; i++) {
          cout << last << " ";
          if (last == 1) {
            last = 2;
          } else {
            last = 1;
          }
        }
        cout << endl;
      }
    }
    if (same == false && space == false) {
      if (n % 2 == 0) {
        cout << 2 << endl;
        for (int i = 0; i < n; i++) {
          cout << (i % 2) + 1 << " ";
        }
      } else {
        cout << 3 << endl;
        for (int i = 0; i < n; i++) {
          if (i == 0) {
            cout << 3 << " ";
          } else {
            cout << (i % 2) + 1 << " ";
          }
        }
      }
      cout << endl;
    }
    while (!v.empty()) {
      v.pop_back();
    }
    while (!c.empty()) {
      c.pop_back();
    }
  }
  return 0;
}
