#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int &e : a) cin >> e;
    int temp = a[0];
    for (int i = 1; i < n; i++)
      if (temp != a[i]) temp = -1;
    if (temp != -1) {
      cout << 1 << endl;
      while (n--) cout << 1 << " ";
      cout << endl;
      continue;
    }
    int l = -1;
    if (a[0] == a[n - 1]) l = n - 1;
    int before = -1;
    for (int i = 1; i < n; i++)
      if (a[i] == a[i - 1]) l = i - 1;
    if (l == -1 && (n & 1)) {
      cout << 3 << endl;
      for (int i = 0; i < n - 1; i++) cout << 1 + (i & 1) << " ";
      cout << 3 << endl;
    } else {
      cout << 2 << endl;
      int before = 0;
      for (int i = 0; i < n; i++) {
        if (!(n & 1) || i != l + 1) before = !before;
        cout << 1 + before << " ";
      }
      cout << endl;
    }
  }
  cin >> t;
}
