#include <bits/stdc++.h>
using namespace std;
int q, n, m, i, j, k, ans = 0;
bool flag, flag1;
int t[200010], a[200010];
int main() {
  cin >> q;
  while (q--) {
    cin >> n;
    flag1 = true;
    for (i = 1; i <= n; i++) {
      cin >> t[i];
      if (t[i] != t[1]) flag1 = false;
    }
    if (flag1) {
      cout << "1" << endl;
      for (i = 1; i <= n; i++) cout << "1 ";
      cout << endl;
      continue;
    }
    for (i = 1; i <= n; i++) a[i] = i % 2;
    if (n % 2 == 0) {
      cout << "2" << endl;
      for (i = 1; i <= n; i++) cout << a[i] + 1 << " ";
      cout << endl;
    } else {
      i = 1;
      flag = false;
      while ((i < n) && (!flag)) {
        if (t[i] == t[i + 1]) {
          flag = true;
          for (j = i + 1; j <= n; j++) {
            a[j] = 1 - a[j];
          }
        }
        i++;
      }
      ans = 2;
      if (a[1] == a[n - 1]) {
        a[n] = 1 - a[1];
      } else {
        if (t[n] != t[n - 1] && t[n] != t[1]) {
          ans = 3;
          a[n] = 2;
        } else if (t[n] == t[n - 1])
          a[n] = a[n - 1];
        else
          a[n] = a[1];
      }
      cout << ans << endl;
      for (i = 1; i <= n; i++) cout << a[i] + 1 << " ";
      cout << endl;
    }
  }
  return 0;
}
