#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
      cin >> vec[i];
    }
    int curr = 1;
    vector<int> ans(n);
    int last_val = vec[0];
    ans[0] = curr;
    bool flag = false;
    for (int i = 1; i < n; i++) {
      if (last_val == vec[i]) {
        ans[i] = curr;
      } else {
        if (curr == 1) {
          curr = 2;
          flag = true;
        } else {
          curr = 1;
        }
        last_val = vec[i];
        ans[i] = curr;
      }
    }
    bool ok = false;
    if ((vec[0] != vec[n - 1]) && (ans[0] == ans[n - 1])) {
      int cnt = 0;
      for (int i = 0; i < n - 1; i++) {
        if (vec[i] == vec[i + 1]) {
          int col = ans[i];
          if (col == 1) {
            last_val = vec[i];
            curr = 2;
            for (int j = i + 1; j < n; j++) {
              if (last_val == vec[j]) {
                ans[j] = curr;
              } else {
                if (curr == 1) {
                  curr = 2;
                  flag = true;
                } else {
                  curr = 1;
                }
                last_val = vec[j];
                ans[j] = curr;
              }
            }
          } else {
            last_val = vec[i];
            curr = 1;
            for (int j = i + 1; j < n; j++) {
              if (last_val == vec[j]) {
                ans[j] = curr;
              } else {
                if (curr == 1) {
                  curr = 2;
                  flag = true;
                } else {
                  curr = 1;
                }
                last_val = vec[j];
                ans[j] = curr;
              }
            }
          }
          ok = true;
          break;
        }
      }
      if (!ok) {
        last_val = vec[n - 1];
        for (int k = n - 1; k >= 0; k--) {
          if (vec[k] != last_val) {
            break;
          }
          ans[k] = 3;
          ok = true;
        }
      }
    }
    curr = 0;
    for (int i = 0; i < n; i++) {
      curr = max(curr, ans[i]);
    }
    cout << curr << endl;
    for (int i = 0; i < n; i++) {
      cout << ans[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
