#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n], f = 0, ind;
    map<int, int> m;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      m[a[i]]++;
      if (i != 0 && a[i] == a[i - 1]) {
        f = 123;
        ind = i;
      }
    }
    if (a[n - 1] == a[0]) {
      f = 123;
      ind = 0;
    }
    if (m[a[0]] == n) {
      cout << 1 << endl;
      for (int i = 0; i < n; i++) {
        cout << 1 << " ";
      }
    } else if (n % 2 == 0) {
      cout << 2 << endl;
      for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
          cout << 1 << " ";
        } else {
          cout << 2 << " ";
        }
      }
    } else {
      if (f == 0) {
        cout << 3 << endl;
        for (int i = 0; i < n - 1; i++) {
          if (i % 2 == 0) {
            cout << 1 << " ";
          } else {
            cout << 2 << " ";
          }
        }
        cout << 3;
      } else {
        cout << 2 << endl;
        int co = 0;
        for (int i = 0; i < n; i++) {
          if (i == ind) {
            co = 1;
          }
          if (i % 2 == 0) {
            cout << 1 + co << " ";
          } else {
            cout << 2 - co << " ";
          }
        }
      }
    }
    cout << endl;
  }
}
