#include <bits/stdc++.h>
using namespace std;
int main() {
  int T, n;
  cin >> T;
  while (T--) {
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    int k = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] != a[0]) {
        k = 1;
        break;
      }
    }
    if (k == 0) {
      cout << 1 << endl;
      for (int i = 0; i < n; i++) {
        cout << 1 << " ";
      }
      cout << endl;
      continue;
    }
    if (n % 2 == 0) {
      cout << 2 << endl;
      for (int i = 0; i < n; i++) {
        cout << i % 2 + 1 << " ";
      }
      cout << endl;
      continue;
    }
    k = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] == a[(i + 1) % n]) {
        vector<int> ans(n);
        for (int j = 0, pos = i + 1; pos < n; pos++, j ^= 1) {
          ans[pos] = j + 1;
        }
        for (int j = 0, pos = i; pos >= 0; pos--, j ^= 1) {
          ans[pos] = j + 1;
        }
        cout << 2 << endl;
        for (int pos = 0; pos < n; pos++) {
          cout << ans[pos] << " ";
        }
        cout << endl;
        k = 1;
        break;
      }
    }
    if (k == 1) {
      continue;
    }
    cout << 3 << endl;
    for (int i = 0; i < n - 1; i++) {
      cout << i % 2 + 1 << " ";
    }
    cout << 3 << endl;
    continue;
  }
  return 0;
}
