#include <bits/stdc++.h>
using namespace std;
int n, t;
int a[200005];
int s[200005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    int pos = 0;
    for (int i = 1; i <= n; i++) cin >> a[i];
    s[1] = 1;
    int k = 0;
    for (int i = 2; i <= n; i++) {
      if (a[i] == a[i - 1])
        s[i] = s[i - 1], pos = i;
      else
        s[i] = 3 - s[i - 1];
      k = max(s[i], k);
    }
    if (a[1] != a[n] && s[1] == s[n]) {
      if (pos > 0) {
        for (int i = pos; i <= n; i++) s[i] = 3 - s[i];
      } else {
        s[n] = 3, k = 3;
      }
    }
    cout << k << endl;
    for (int i = 1; i <= n; i++) cout << s[i] << " ";
    cout << endl;
  }
  return 0;
}
