#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n];
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
    }
    long long b[n], count = 1, flag = 0;
    for (long long i = 1; i < n; i++) {
      if (a[i] != a[i - 1]) {
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      cout << "1\n";
      for (long long i = 0; i < n; i++) {
        cout << 1 << " ";
      }
      cout << endl;
    } else {
      if (n % 2 == 0) {
        cout << 2 << endl;
        for (long long i = 0; i < n; i++) {
          if (i % 2 == 0) {
            cout << 1 << " ";
          } else {
            cout << 2 << " ";
          }
        }
        cout << endl;
      } else {
        long long b[n], flag1 = 0;
        map<long long, long long> mp;
        b[0] = 1;
        for (long long i = 1; i < n; i++) {
          if (flag1 == 0 && a[i] == a[i - 1]) {
            flag1 = 1;
            b[i] = b[i - 1];
          } else {
            if (b[i - 1] == 1) {
              b[i] = 2;
            } else {
              b[i] = 1;
            }
          }
        }
        if (flag1 == 0) {
          if (a[n - 1] != a[0]) {
            b[n - 1] = 3;
          }
        }
        for (long long i = 0; i < n; i++) {
          mp[b[i]] = 1;
        }
        cout << mp.size() << endl;
        for (long long i = 0; i < n; i++) {
          cout << b[i] << " ";
        }
        cout << endl;
      }
    }
  }
}
