#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ll modExpo(ll a, ll exp, ll mod) {
  ll res = 1;
  while (exp) {
    if (exp & 1) res *= a, res %= mod;
    exp = exp >> 1, a *= a, a %= mod;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    vector<deque<int>> dq;
    dq.push_back(deque<int>{});
    dq.back().push_back(0);
    for (int i = 1; i < n; i++) {
      if (a[i] != a[i - 1]) {
        dq.push_back(deque<int>{});
      }
      dq.back().push_back(i);
    }
    if (dq.size() > 1 and a.front() == a.back()) {
      reverse(begin(dq.back()), end(dq.back()));
      for (int i : dq.back()) {
        dq.front().push_front(i);
      }
      dq.pop_back();
    }
    vector<int> res(n);
    if (dq.size() == 1) {
      cout << 1 << '\n';
      int temp = 0;
      for (const auto& v : dq) {
        for (int i = 0; i < (int)v.size(); i++) {
          res[v[i]] = temp + 1;
        }
        temp = !temp;
      }
    } else {
      if (dq.size() & 1) {
        bool one = true;
        for (const auto& i : dq) {
          if (i.size() > 1) one = false;
        }
        if (one) {
          cout << 3 << '\n';
          int temp = 0;
          for (const auto& v : dq) {
            for (int i = 0; i < (int)v.size(); i++) {
              res[v[i]] = temp + 1;
            }
            temp = !temp;
          }
          res.back() = 3;
        } else {
          cout << 2 << '\n';
          int i;
          for (i = 0; i < (int)dq.size(); i++) {
            if (dq[i].size() > 1) {
              res[dq[i][0]] = 1;
              for (int j = 1; j < (int)dq[i].size(); j++) {
                res[dq[i][j]] = 2;
              }
              break;
            }
          }
          int temp = 1;
          for (int j = i - 1; j >= 0; j--) {
            for (int k = 0; k < (int)dq[j].size(); k++) {
              res[dq[j][k]] = temp + 1;
            }
            temp = !temp;
          }
          temp = 0;
          for (int j = i + 1; j < (int)dq.size(); j++) {
            for (int k = 0; k < (int)dq[j].size(); k++) {
              res[dq[j][k]] = temp + 1;
            }
            temp = !temp;
          }
        }
      } else {
        cout << 2 << '\n';
        int temp = 0;
        for (const auto& v : dq) {
          for (int i = 0; i < (int)v.size(); i++) {
            res[v[i]] = temp + 1;
          }
          temp = !temp;
        }
      }
    }
    for (int i = 0; i < n; i++) {
      cout << res[i] << " \n"[i == n - 1];
    }
  }
  return 0;
}
