#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  for (int a = 1; a <= t; a++) {
    int n;
    cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
    }
    bool same = true;
    for (int i = 0; i < n - 1; i++) {
      if (arr[i] != arr[i + 1]) {
        same = false;
        break;
      }
    }
    if (same) {
      cout << "1\n";
      for (int i = 0; i < n; i++) {
        cout << "1 ";
      }
      cout << "\n";
      continue;
    }
    if (n % 2 == 0 || arr[0] == arr[n - 1]) {
      cout << "2\n";
      for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
          cout << "1 ";
        } else {
          cout << "2 ";
        }
      }
      cout << "\n";
      continue;
    }
    int key = -1;
    for (int i = 0; i < n - 1; i++) {
      if (arr[i] == arr[i + 1]) {
        key = i;
        break;
      }
    }
    if (key != -1) {
      cout << "2\n";
      for (int i = 0; i < n; i++) {
        if ((i % 2 == 0 && i <= key) || (i % 2 == 1 && i > key)) {
          cout << "1 ";
        } else {
          cout << "2 ";
        }
      }
      cout << "\n";
      continue;
    }
    cout << "3\n";
    for (int i = 0; i < n - 1; i++) {
      if (i % 2 == 0) {
        cout << "1 ";
      } else {
        cout << "2 ";
      }
    }
    cout << "3\n";
  }
  return 0;
}
