#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int r = 0; r < t; r++) {
    long long n, m, k, i, j, x, y, z, ans = 0, flag = 0;
    cin >> n;
    vector<int> a(n);
    for (i = 0; i < n; i++) cin >> a[i];
    long long changes = 0;
    for (i = 0; i < n; i++) {
      if (a[(i + 1) % n] != a[i])
        changes++;
      else
        flag = 1;
    }
    if (n % 2 == 0 && changes > 0) {
      cout << "2\n";
      for (i = 0; i < n; i++) {
        cout << (i % 2) + 1 << " ";
      }
      cout << "\n";
      continue;
    }
    if (changes == 0) {
      cout << "1\n";
      for (i = 0; i < n; i++) cout << "1 ";
      cout << "\n";
      continue;
    }
    if (changes % 2 != 0 && flag == 0) {
      cout << "3\n";
      for (i = 0; i < n - 1; i++) {
        cout << (i % 2) + 1 << " ";
      }
      cout << "3\n";
    } else {
      x = 2, y = 1;
      cout << "2\n";
      for (i = 0; i < n; i++) {
        if (a[(i + 1) % n] != a[i]) {
          cout << x << " ";
          swap(x, y);
        } else if (changes % 2 != 0 && flag == 1) {
          cout << x << " ";
          swap(x, y);
          flag = 0;
        } else
          cout << x << " ";
      }
      cout << "\n";
    }
  }
  return 0;
}
