#include <bits/stdc++.h>
using namespace std;
int k = 1;
vector<int> c;
void dfs(int u, vector<vector<int>> &adj, vector<bool> &visited) {
  visited[u] = true;
  for (int i = 0; i < adj[u].size(); ++i) {
    int v = adj[u][i];
    if (!visited[v]) {
      dfs(v, adj, visited);
      c[u] = (1 + c[v]) % k;
      if (c[u] == c[v]) {
        ++k;
        c[u] = k - 1;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    k = 1;
    vector<int> t(n);
    c.resize(n, 0);
    for (int i = 0; i < n; ++i) c[i] = 0;
    vector<vector<int>> adj(n);
    for (int i = 0; i < n; ++i) cin >> t[i];
    for (int i = 0; i < n; ++i) {
      if (t[i] != t[(i + 1) % n]) {
        adj[i].push_back((i + 1) % n);
        adj[(i + 1) % n].push_back(i);
      }
    }
    vector<bool> visited(n, false);
    for (int i = 0; i < n; ++i) {
      if (adj[i].size() <= 1) dfs(i, adj, visited);
    }
    if (!visited[0]) {
      k = 2;
      if (n % 2) {
        --n;
        cout << "3\n3 ";
      } else
        cout << k << endl;
      for (int i = 0; i < n; ++i) cout << i % k + 1 << " ";
      cout << endl;
    } else {
      cout << k << endl;
      for (int i = 0; i < n; ++i) cout << c[i] + 1 << " ";
      cout << endl;
    }
  }
}
