#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, st, en, b, i;
    long long int k, p = 0, q = 0, la = 0;
    cin >> n;
    long long int a[n];
    map<long long int, long long int> m;
    for (i = 0; i < n; i++) {
      cin >> a[i];
      m[a[i]]++;
    }
    for (i = 1; i < n; i++) {
      if (a[i] == a[i - 1]) q = 1;
    }
    if (n % 2 == 0 and m.size() > 1) {
      cout << "2\n";
      for (i = 0; i < n; i++) {
        if (i % 2 == 0)
          cout << "1 ";
        else
          cout << "2 ";
      }
      cout << "\n";
      continue;
    }
    if (m.size() == 1) {
      cout << "1\n";
      for (i = 0; i < n; i++) cout << "1 ";
      cout << "\n";
      continue;
    }
    if (n % 2 == 1 and q == 0 and a[n - 1] != a[0])
      k = 3;
    else
      k = 2;
    cout << k << "\n";
    p = 0;
    if (k == 3) {
      for (i = 0; i < n; i++) {
        if (i == n - 1)
          cout << "3 ";
        else if (i % 2 == 0)
          cout << "1 ";
        else if (i % 2 == 1)
          cout << "2 ";
      }
      cout << "\n";
    } else if (k == 2) {
      cout << "1 ";
      la = 1;
      for (i = 1; i < n;) {
        if (i == n - 1 and p == 0) {
          if (a[i] == a[i - 1]) {
            cout << la << " ";
            la = 3 - la;
            p = 1;
          } else if (a[i] == a[0]) {
            cout << "1 ";
          }
          i++;
        } else if (a[i] == a[i - 1] and p == 0) {
          cout << la << " ";
          la = 3 - la;
          p = 1;
          cout << la << " ";
          i += 2;
        } else {
          la = 3 - la;
          cout << la << " ";
          i++;
        }
      }
      cout << "\n";
    }
  }
  return 0;
}
