#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long MAX = 1e5 + 10;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n + 1];
    set<int> s;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      s.insert(a[i]);
    }
    a[n] = a[0];
    if (s.size() == 1) {
      cout << 1 << "\n";
      for (int i = 0; i < n; i++) cout << 1 << " ";
    } else if (n % 2 == 0) {
      cout << 2 << "\n";
      for (int i = 0; i < n / 2; i++) cout << 1 << " " << 2 << " ";
    } else if (n & 1) {
      bool x = true;
      int j = -1;
      for (int i = 1; i < n + 1; i++)
        if (a[i] == a[i - 1]) {
          x = false;
          j = i - 1;
          break;
        }
      if (x) {
        cout << 3 << "\n";
        for (int i = 0; i < n / 2; i++) cout << 1 << " " << 2 << " ";
        cout << 3;
      } else {
        cout << 2 << "\n";
        for (int i = 0; i < j; i++)
          if (i % 2 == 0)
            cout << 1 << " ";
          else
            cout << 2 << " ";
        if (j % 2) {
          cout << 2 << " ";
          for (int i = j + 1; i < n; i++)
            if (i % 2 == 0)
              cout << 2 << " ";
            else
              cout << 1 << " ";
        } else {
          cout << 1 << " ";
          for (int i = j + 1; i < n; i++)
            if (i % 2 == 0)
              cout << 2 << " ";
            else
              cout << 1 << " ";
        }
      }
    }
    cout << "\n";
  }
}
