#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)2e5;
int n, a[MAXN + 5], sol[MAXN + 5];
vector<int> ms[MAXN + 5];
bool bio[MAXN + 5];
bool dfs(int first) {
  bio[first] = 1;
  bool ret = 1;
  for (vector<int>::iterator i = ms[first].begin(); i != ms[first].end(); ++i) {
    int o = *i;
    if (bio[o]) {
      ret &= (sol[first] != sol[o]);
      continue;
    }
    sol[o] = sol[first] ^ 1;
    ret &= dfs(o);
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int temp;
  cin >> temp;
  while (temp--) {
    for (int i = 1; i <= n; ++i) {
      ms[i].clear();
      bio[i] = 0;
      sol[i] = 0;
    }
    cin >> n;
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
    }
    int br = 0;
    for (int i = 1; i <= n; ++i) {
      int first = i;
      int second = (i % n + 1);
      if (a[first] != a[second]) {
        ms[first].push_back(second);
        ms[second].push_back(first);
        br++;
      }
    }
    if (!br) {
      cout << 1 << endl;
      for (int i = 1; i <= n; ++i) {
        cout << 1 << ' ';
      }
      cout << endl;
      continue;
    }
    bool moze = 1;
    for (int i = 1; i <= n; ++i) {
      if (!bio[i]) {
        moze &= dfs(i);
      }
    }
    if (moze) {
      cout << 2 << endl;
      for (int i = 1; i <= n; ++i) {
        int val = sol[i] + 1;
        cout << val << ' ';
      }
      cout << endl;
    } else {
      sol[1] = 0;
      for (int i = 2; i < n; ++i) {
        if (a[i] == a[i - 1]) {
          sol[i] = sol[i - 1];
        } else {
          sol[i] = (sol[i - 1] ^ 1);
        }
      }
      sol[n] = 2;
      cout << 3 << endl;
      for (int i = 1; i <= n; ++i) {
        cout << sol[i] + 1 << ' ';
      }
      cout << endl;
    }
  }
  return 0;
}
