#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int M = 1e9 + 7;
const long double dinf = 0x3f3f3f3f3f3f3f3f;
int a[maxn], b[maxn];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int t = 1;
    for (int i = (0); i < (n); i++) {
      cin >> a[i];
    }
    int f = 0;
    int k = 0;
    int ff = 0;
    for (int i = (0); i < (n); i++) {
      int r = (i + 1) % n;
      if (a[i] == a[r]) {
        k = r;
        ff = 1;
      }
      if (a[i] != a[r]) {
        f = 1;
      }
    }
    if (!f) {
      t = 1;
      for (int i = (0); i < (n); i++) b[i] = 1;
    } else if (!ff && n % 2 != 0) {
      t = b[0] = 3;
      for (int i = (1); i < (n); i++) b[i] = (i & 1) + 1;
    } else {
      t = 2;
      if (n % 2 == 0) ff = 0;
      for (int i = (0); i < (n); i++) b[i] = 0;
      if (ff) {
        int l = (k - 1 + n) % n;
        int r = k;
        b[l] = b[r] = 1;
      }
      int fff = 1;
      for (int i = (k + 1) % n; !b[i]; i = (i + 1) % n) {
        b[i] = fff + 1;
        fff = !fff;
      }
    }
    cout << t << '\n';
    for (int i = (0); i < (n); i++) {
      cout << b[i] << ' ';
    }
    cout << '\n';
  }
}
