#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  int n;
  int t[200000];
  for (int l = 0; l < q; l++) {
    cin >> n;
    bool same = 0;
    bool notsame = 0;
    for (int i = 0; i < n; i++) cin >> t[i];
    for (int i = 0; i < n; i++) {
      same = same || (t[(i + 1) % n] == t[i]);
      notsame = notsame || (t[(i + 1) % n] != t[i]);
    }
    if (!notsame) {
      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;
    }
    if (!same) {
      cout << 3 << "\n";
      for (int i = 0; i < n - 1; i++) cout << (i % 2) + 1 << " ";
      cout << "3 ";
      cout << "\n";
      continue;
    }
    bool flag = 1;
    int u = 0;
    cout << 2 << "\n";
    for (int i = 0; i < n; i++) {
      cout << u % 2 + 1 << " ";
      if ((t[(i + 1) % n] == t[i]) && flag)
        flag = 0;
      else
        u = (u + 1) % 2;
    }
    cout << "\n";
  }
}
