#include <bits/stdc++.h>
using namespace std;
int main() {
  int q, n, i;
  cin >> q;
  while (q--) {
    cin >> n;
    int t[n], c[n], k, flag = 1;
    for (i = 0; i < n; i++) cin >> t[i];
    for (i = 0; i < n - 1; i++)
      if (t[i] != t[i + 1]) {
        flag = 0;
        break;
      }
    if (flag == 1) {
      cout << 1 << "\n";
      for (i = 0; i < n; i++) cout << "1 ";
      cout << "\n";
    } else {
      if (n % 2 == 0) {
        for (i = 0; i < n; i += 2) {
          c[i] = 1;
          c[i + 1] = 2;
        }
        cout << "2\n";
      } else {
        c[0] = 1;
        for (i = 1; i < n; i++) {
          if (flag == 0 && t[i] == t[i - 1]) {
            c[i] = c[i - 1];
            flag = 1;
            cout << "2\n";
          } else if (c[i - 1] == 1)
            c[i] = 2;
          else
            c[i] = 1;
        }
        if (flag == 0 && t[0] == t[n - 1]) {
          cout << "2\n";
          flag = 1;
          c[n - 1] = 1;
        }
        if (flag == 0) {
          cout << "3\n";
          c[n - 1] = 3;
        }
      }
      for (i = 0; i < n; i++) cout << c[i] << " ";
      cout << "\n";
    }
  }
  return 0;
}
