#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int MAX = 1000000;
vector<int> o(MAX);
void solve() {
  int n, cnt = 0;
  cin >> n;
  vector<int> t(n);
  for (int i = 0; i < n; i++) {
    cin >> t[i];
    o[t[i]]++;
    cnt += (o[t[i]] == 1);
  }
  int even = -1;
  vector<int> ans;
  for (int i = 0; i < n - 1; i++) {
    if (t[i] == t[i + 1]) {
      even = i;
      break;
    }
  }
  if (cnt == 1) {
    ans.push_back(1);
    for (int i = 0; i < n; i++) {
      ans.push_back(1);
    }
  } else if (cnt == 2) {
    int mn = *min_element(t.begin(), t.end());
    ans.push_back(2);
    for (int i = 0; i < n; i++) {
      if (t[i] == mn) {
        ans.push_back(1);
      } else {
        ans.push_back(2);
      }
    }
  } else if (t[0] == t[n - 1] || !(n & 1)) {
    ans.push_back(2);
    for (int i = 0; i < n; i++) {
      ans.push_back(i % 2 + 1);
    }
  } else {
    if (~even) {
      ans.push_back(2);
      for (int i = 0; i < n; i++) {
        if (i <= even) {
          ans.push_back(i % 2 + 1);
        } else {
          ans.push_back((i + 1) % 2 + 1);
        }
      }
    } else {
      ans.push_back(3);
      for (int i = 0; i < n - 1; i++) {
        ans.push_back(i % 2 + 1);
      }
      ans.push_back(3);
    }
  }
  for (int i = 0; i < n; i++) {
    o[t[i]]--;
  }
  cout << ans[0] << "\n";
  for (int i = 0; i < n; i++) {
    cout << ans[i + 1] << " ";
  }
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
