#include <bits/stdc++.h>
using namespace std;
long long int mod(long long int x) { return x % 1000000007; }
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int mod(long long int num, long long int den) {
  return mod(mod(num) * power(den, 1000000007 - 2, 1000000007));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    vector<long long int> arr(n);
    bool one = true;
    for (long long int i = 0; i < n; ++i) {
      cin >> arr[i];
      if (i - 1 >= 0)
        if (arr[i] != arr[i - 1]) one = false;
    }
    if (one) {
      cout << 1 << "\n";
      for (long long int i = 0; i < n; ++i) cout << 1 << " ";
      cout << "\n";
      continue;
    }
    if (n % 2 == 0) {
      cout << 2 << "\n";
      for (long long int i = 0; i < n; ++i) {
        cout << (i) % 2 + 1 << " ";
      }
      cout << "\n";
      continue;
    }
    long long int pos = -1;
    for (long long int i = 0; i < (n - 1); ++i) {
      if (arr[i] == arr[i + 1]) {
        pos = i;
        break;
      }
    }
    if (pos != -1) {
      cout << 2 << "\n";
      long long int co = 0;
      for (long long int i = 0; i < n; ++i) {
        cout << (co) % 2 + 1 << " ";
        if (i != (pos)) {
          co++;
        }
      }
      cout << "\n";
      continue;
    }
    if (arr[0] == arr[n - 1]) {
      cout << 2 << "\n";
      for (long long int i = 0; i < n; ++i) cout << i % 2 + 1 << " ";
      cout << "\n";
      continue;
    }
    cout << 3 << "\n";
    for (long long int i = 0; i < n - 1; ++i) cout << i % 2 + 1 << " ";
    cout << 3 << "\n";
  }
}
