#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n], flag = 0, flag2 = 0, flag4 = 0, k = 1;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n - 1; i++) {
      if (a[i + 1] != a[i]) flag++;
      if (a[i + 1] == a[i]) flag2++;
      if (a[0] == a[n - 1]) flag4++;
    }
    if (flag == 0) {
      cout << "1\n";
      for (int i = 0; i < n; i++) cout << k << ' ';
    } else if (n % 2 == 0) {
      cout << "2\n";
      for (int i = 0; i < n; i++) {
        cout << k << ' ';
        k = 3 - k;
      }
    } else if (flag2) {
      int flag3 = 0;
      cout << "2\n";
      for (int i = 0; i < n; i++) {
        if (a[i] == a[i + 1] && flag3 == 0) {
          cout << k << ' ' << k << ' ';
          i++;
          flag3++;
          k = 3 - k;
        } else {
          cout << k << ' ';
          k = 3 - k;
        }
      }
    } else if (flag4) {
      cout << "2\n";
      for (int i = 0; i < n - 1; i++) {
        cout << k << ' ';
        k = 3 - k;
      }
      cout << "1 ";
    } else {
      cout << "3\n";
      for (int i = 0; i < n - 1; i++) {
        cout << k << ' ';
        k = 3 - k;
      }
      cout << "3 ";
    }
    cout << endl;
  }
  return 0;
}
